|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectRotor
public class Rotor
A Rotor
is a rotating part of an EnigmaMachine
.
This implementation provides 5 types of rotors which will be referred as
1, 2, 3, 4, 5 representing the wirings of rotor types I, II, III, IV, V
used in the enigma M3 machine. Each rotor type has a specific wiring
which represents a permutation and determines to which letter an
incoming letter will be encoded to. As the Rotor
steps,
it changes the "rotor position" and so the position of the incoming
letter with respect to the rotor wiring. The stepping of the rotor
is controlled via calls to the method step
and affects
the current rotor position.
Constructor Summary | |
---|---|
Rotor(int rotorType)
A constructor of arity 1 that specifies the rotor type. |
|
Rotor(int rotorType,
char startPosition)
A constructor of arity 2 that specifies the rotor type and initial position. |
Method Summary | |
---|---|
boolean |
atNotch()
Method atNotch indicates whether the current rotor position
is at the rotor notch (a special position that may make a rotor next
to this to step) |
char |
getCurrentPosition()
Method getCurrentPosition returns the current letter
position of this rotor. |
char |
getInitialPosition()
Method getInitialPosition returns the initial position
of this rotor. |
char |
getNotch()
Method getNotch returns the notch position of the rotor |
java.lang.String |
getType()
Return the rotor type. |
java.lang.String |
getWiring()
Method getWiring returns the wiring encoding of this rotor |
char |
outLetter(char inputLetter,
boolean forward)
Method outLetter produces the resulting letter obtained
from the the given letter entering one of the sides of the rotor |
void |
resetRotorPosition()
Method resetRotorPosition makes the current rotor
position to go back to the initial rotor position. |
void |
setInitialRotorPosition(char letter)
Method setInitialRotorPosition sets both the rotor
initial position and the rotor current position to the given letter. |
void |
step()
Method step makes the rotor advance its position by one
letter of the alphabet (e.g. |
java.lang.String |
toString()
This method overrides java.lang.Object.toString() and returns a string representation of this Rotor . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Rotor(int rotorType)
rotorType
- is a number 1..5 specifying types I..Vpublic Rotor(int rotorType, char startPosition)
rotorType
- is a number 1..5 specifying types I..VstartPosition
- is a capital letter 'A' to 'Z' specifying
the initial rotor positionMethod Detail |
---|
public java.lang.String getType()
public java.lang.String getWiring()
getWiring
returns the wiring encoding of this rotor
public char getInitialPosition()
getInitialPosition
returns the initial position
of this rotor.
public char getCurrentPosition()
getCurrentPosition
returns the current letter
position of this rotor.
public char outLetter(char inputLetter, boolean forward)
outLetter
produces the resulting letter obtained
from the the given letter entering one of the sides of the rotor
inputLetter
- is the letter entering the rotorforward
- specifies the direction of the encoding; true specifies
the usual direction and false specifies the opposite direction
public void step()
step
makes the rotor advance its position by one
letter of the alphabet (e.g. if its position was 'A' after stepping
it becomes 'B' and if it was 'Z' after stepping it becomes 'A')
public void setInitialRotorPosition(char letter)
setInitialRotorPosition
sets both the rotor
initial position and the rotor current position to the given letter.
letter
- is the new value for initial rotor position and current
rotor position.public void resetRotorPosition()
resetRotorPosition
makes the current rotor
position to go back to the initial rotor position.
public boolean atNotch()
atNotch
indicates whether the current rotor position
is at the rotor notch (a special position that may make a rotor next
to this to step)
public char getNotch()
getNotch
returns the notch position of the rotor
public java.lang.String toString()
Rotor
.
toString
in class java.lang.Object
Rotor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |