-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBox.java
57 lines (52 loc) · 1.18 KB
/
Box.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
/**
* Creates, modifies, and returns information about
* a box in the Deal Game
*
* @author Sean DeZurik
*/
public class Box {
/** Monetary value in the box */
private double value;
/** Whether or not the box has been opened */
private boolean isOpen;
/**
* Constructor
*
* @param value a double with value for the box
*/
public Box(double value) {
this.value = value;
isOpen = false;
}
/**
* Getter method for value
*
* @return a double with value in box
*/
public double getValue() {
return value;
}
/**
* Gives status whether box is open or not
*
* @return a boolean that is true if box is open
* and false if the box is not open
*/
public boolean isOpen() {
return isOpen;
}
/**
* Sets the state of the box as open
*/
public void open() {
isOpen = true;
}
/**
* Gives textual representation of the object
*
* @return a String with text representation of object
*/
public String toString() {
return "Open: " + isOpen() + " Value: " + getValue();
}
}