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

Merge branch 'master' into 'master'

Walzen Klasse bearbeitet. Walzen drehen nun korrekt

Closes #12

See merge request !67
parents 65b831e8 151e870f
No related branches found
No related tags found
No related merge requests found
package projekt.enigma.model; package projekt.enigma.model;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* Klasse Walze * Klasse Walze
...@@ -138,16 +135,14 @@ public class Walze { ...@@ -138,16 +135,14 @@ public class Walze {
public boolean dreheWalze(int richtung) { public boolean dreheWalze(int richtung) {
boolean checkRing = false; boolean checkRing = false;
if (richtung == 1) { if (richtung == 1) {
Collections.rotate(Arrays.asList(this.walzeAlpha), richtung); Collections.rotate(Arrays.asList(this.walzeAlpha), richtung);
} else { } else {
richtung = -1; richtung = -1;
Collections.rotate(Arrays.asList(this.walzeAlpha), richtung); Collections.rotate(Arrays.asList(this.walzeAlpha), richtung);
} }
System.out.printf("W: %s R: %s\n", this.getPosition(), this.ringstellung);
// gleicht die Ringstellung mit der aktuellen Position ab // gleicht die Ringstellung mit der aktuellen Position ab
if (this.getPosition() + 1 == this.ringstellung) { if (this.getPosition() + 1 == this.ringstellung) {
checkRing = true; checkRing = true;
} }
......
...@@ -17,9 +17,9 @@ public class WalzeTest { ...@@ -17,9 +17,9 @@ public class WalzeTest {
@Test @Test
public void dreheWalze() { public void dreheWalze() {
Walze w = new Walze(1, 3); 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(); 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 @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