-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiceCup.java
61 lines (54 loc) · 1.07 KB
/
DiceCup.java
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* A class that hold a dice box which stores three dices
* @author Ryu Sonoda
*
*/
public class DiceCup {
private Dice dice1;
private Dice dice2;
private Dice dice3;
/**
* Construct a dice box that stores three dices
*/
public DiceCup () {
dice1 = new Dice();
dice2 = new Dice();
dice3 = new Dice();
}
/**
* Roll three dices in the dice box
*/
public void rollDices () {
dice1.roll();
dice2.roll();
dice3.roll();
}
/**
* Check whether the all dices have the same pip
* @return true if the all dices have the same pip, false otherwise.
*/
public boolean arePipsSame() {
return (dice1.getPip() == dice2.getPip()) && (dice1.getPip() == dice3.getPip());
}
/**
* Get the pip of the first dice
* @return the pip of the first dice
*/
public Dice getDice1() {
return dice1;
}
/**
* Get the pip of the second dice
* @return the pip of the second dice
*/
public Dice getDice2() {
return dice2;
}
/**
* Get the pip of the third dice
* @return the pip of the third dice
*/
public Dice getDice3() {
return dice3;
}
}