Skip to content
Snippets Groups Projects
Commit 151e870f authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Walzen Klasse bearbeitet. Walzen drehen nun korrekt

parent 65b831e8
No related branches found
No related tags found
No related merge requests found
package projekt.enigma.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Klasse Walze
......@@ -138,16 +135,14 @@ public class Walze {
public boolean dreheWalze(int richtung) {
boolean checkRing = false;
if (richtung == 1) {
Collections.rotate(Arrays.asList(this.walzeAlpha), richtung);
} else {
richtung = -1;
Collections.rotate(Arrays.asList(this.walzeAlpha), richtung);
}
System.out.printf("W: %s R: %s\n", this.getPosition(), this.ringstellung);
if (richtung == 1) {
Collections.rotate(Arrays.asList(this.walzeAlpha), richtung);
} else {
richtung = -1;
Collections.rotate(Arrays.asList(this.walzeAlpha), richtung);
}
// gleicht die Ringstellung mit der aktuellen Position ab
// gleicht die Ringstellung mit der aktuellen Position ab
if (this.getPosition() + 1 == this.ringstellung) {
checkRing = true;
}
......
......@@ -17,9 +17,9 @@ public class WalzeTest {
@Test
public void dreheWalze() {
Walze w = new Walze(1, 3);
assertFalse("false erwartet, true geliefert", w.dreheWalze(2));
assertFalse("false erwartet, true geliefert", w.dreheWalze(1));
char temp = w.getAnzeige();
Assert.assertEquals("C erwartet, " + temp + " zurück gegeben", 'C', temp);
Assert.assertEquals("B erwartet, " + temp + " zurück gegeben", 'B', temp);
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment