Class Test
java.lang.Object
Test
public class Test
- extends java.lang.Object
Constructor Summary |
Test()
|
Method Summary |
static EnigmaMachine |
buildEnigmaMachine(int r1,
int r2,
int r3,
int refl,
char startPos1,
char startPos2,
char startPos3,
boolean stepping)
This creates an enigma machine, given its characteristics. |
static void |
main(java.lang.String[] args)
Provides a basic set of testing for the EnigmaMachine class. |
static boolean |
testEnigmaMachine(EnigmaMachine M3,
java.lang.String plainText)
Tests an EnigmaMachine with a given plaintext. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Test
public Test()
buildEnigmaMachine
public static EnigmaMachine buildEnigmaMachine(int r1,
int r2,
int r3,
int refl,
char startPos1,
char startPos2,
char startPos3,
boolean stepping)
- This creates an enigma machine, given its characteristics.
- Parameters:
r1
- is the type of rotor 1 (right rotor)r2
- is the type of rotor 2 (middle rotor)r3
- is the type of rotor 3 (left rotor)refl
- is the type of the reflectorstartPos1
- is the start position of rotor 1startPos2
- is the start position of rotor 1startPos3
- is the start position of rotor 1stepping
- specifies if rotors step (true is the default position
and the only one that can matych the behaviour of the mentioned
emulator; setting stepping to false allows you to test the rotors
independently of your machine doing the stepping correctly.
- Returns:
- an EnigmaMachine with the given characteristics
testEnigmaMachine
public static boolean testEnigmaMachine(EnigmaMachine M3,
java.lang.String plainText)
- Tests an EnigmaMachine with a given plaintext. It first encodes the
plaintext into a cyphertext. Then it runs the cyphertext into the
enigma machine obtaining a decyphered text which is verified if it
matches with the original plaintext; the result of this verification
is returned. If in verbose mode, it prints the enigma machine before
and after encoding as well as the plaintext, cyphertext, decyphertext.
- Parameters:
M3
- is an enigma machineplainText
- is a plaintext
- Returns:
- true if and only if M3 encodes and decodes compatibly
(i.e. M3 applied to result of M3 applied to plaintext equals plaintext)
main
public static void main(java.lang.String[] args)
- Provides a basic set of testing for the
EnigmaMachine
class.
- Parameters:
args
-