I think the bug is gone now. Let's focus on the features again.

I'm planning to make the machine more understandable ("live"-rotor movements etc.)
This commit is contained in:
vanitasvitae 2015-02-16 13:56:05 +01:00
parent 664f77fe9c
commit 8fecb6f7b7
3 changed files with 5 additions and 5 deletions

View file

@ -16,8 +16,8 @@ public class Enigma
private Rotor r3; private Rotor r3;
//Slot for the reflector //Slot for the reflector
private Rotor reflector; private Rotor reflector;
//Standard configuration (rotors 1-3, reflector A, all three rotors set to position 1) //Standard configuration (rotors 1-3, reflector B, all three rotors set to position 1)
private static final int[] STANDARD_CONFIGURATION = {1,2,3,1,1,1,1}; private static final int[] STANDARD_CONFIGURATION = {1,2,3,2,1,1,1};
/** /**
* Create new Enigma with given configuration. * Create new Enigma with given configuration.

View file

@ -120,7 +120,7 @@ public class MainActivity extends Activity
w1.setSelection(0); w1.setSelection(0);
w2.setSelection(1); w2.setSelection(1);
w3.setSelection(2); w3.setSelection(2);
reversingRotor.setSelection(0); reversingRotor.setSelection(1);
w1pos.setSelection(0); w1pos.setSelection(0);
w2pos.setSelection(0); w2pos.setSelection(0);
w3pos.setSelection(0); w3pos.setSelection(0);

View file

@ -144,7 +144,7 @@ public class Rotor
public int encryptForward(int x) public int encryptForward(int x)
{ {
return this.rotor[(26+x+ringsetting)%26]; return this.rotor[(26+x+ringsetting)%26];
} //TODO: Verify "+ringsetting" }
/**encrypt in backward direction (coming from the reversing rotor) /**encrypt in backward direction (coming from the reversing rotor)
* @param x incoming character * @param x incoming character
@ -152,7 +152,7 @@ public class Rotor
*/ */
public int encryptBackward(int x) public int encryptBackward(int x)
{ {
if(this.rrotor == null) return this.rotor[(26+x+ringsetting)%26]; //TODO: Verify "+ringsetting" if(this.rrotor == null) return this.rotor[(26+x+ringsetting)%26];
else return this.rrotor[(26+x)%26]; else return this.rrotor[(26+x)%26];
} }