refactor
This commit is contained in:
parent
5926655a54
commit
0cd27b8d31
@ -54,7 +54,7 @@ public class Game {
|
|||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
int i = Integer.parseInt(line);
|
int i = Integer.parseInt(line);
|
||||||
player.toggleMark(i);
|
player.toggleMarked(i);
|
||||||
System.out.println(player);
|
System.out.println(player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class Player implements DiceInteraction{
|
|||||||
.forEach(Dice::roll);
|
.forEach(Dice::roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleMark(int diceIdx) throws SelectionException {
|
public void toggleMarked(int diceIdx) throws SelectionException {
|
||||||
if (diceIdx < 0 || diceIdx >= dices.length) {
|
if (diceIdx < 0 || diceIdx >= dices.length) {
|
||||||
throw new SelectionException("Invalid dice index: " + diceIdx);
|
throw new SelectionException("Invalid dice index: " + diceIdx);
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ public class Player implements DiceInteraction{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int changeDiceState(int diceIdx) throws SelectionException {
|
public int changeDiceState(int diceIdx) throws SelectionException {
|
||||||
toggleMark(diceIdx);
|
toggleMarked(diceIdx);
|
||||||
return roundScore + selectionScore();
|
return roundScore + selectionScore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class PlayerTest {
|
|||||||
|
|
||||||
int diceIdx = 1;
|
int diceIdx = 1;
|
||||||
|
|
||||||
player.toggleMark(diceIdx);
|
player.toggleMarked(diceIdx);
|
||||||
expected = "0 + 50: 4 (5) 6 6 2 6 ";
|
expected = "0 + 50: 4 (5) 6 6 2 6 ";
|
||||||
assertEquals(expected, player.toStringHelper());
|
assertEquals(expected, player.toStringHelper());
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class PlayerTest {
|
|||||||
expected = "0 + 50: 1 [5] 2 5 4 2 ";
|
expected = "0 + 50: 1 [5] 2 5 4 2 ";
|
||||||
assertEquals(expected, player.toStringHelper());
|
assertEquals(expected, player.toStringHelper());
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> player.toggleMark(diceIdx));
|
assertThrows(IllegalArgumentException.class, () -> player.toggleMarked(diceIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user