forked from fjricci/monopoly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputDice.java
More file actions
38 lines (33 loc) · 750 Bytes
/
InputDice.java
File metadata and controls
38 lines (33 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package monopoly;
/**
* Created by fjricci on 4/7/2015.
* Player-determined dice rolls.
*/
public class InputDice implements Dice {
private final int N;
private final int SIDES;
private final Input input;
public InputDice(Input input) {
N = 2;
SIDES = 6;
this.input = input;
}
//return number of dice
public int numDice() {
return N;
}
//return sides per die
public int sides() {
return SIDES;
}
public Roll roll() {
System.out.println("Please enter a manual dice roll, one die per line.");
while (true) {
Roll roll = input.inputRoll();
if (roll.val < N || roll.val > N * SIDES)
System.out.println("Please enter a valid dice roll.");
else
return roll;
}
}
}