|
@@ -9,7 +9,7 @@
|
9
|
9
|
* @author David J. Barnes and Michael Kolling
|
10
|
10
|
* @version 2008.03.30
|
11
|
11
|
*/
|
12
|
|
-public class TicketMachine
|
|
12
|
+ public class TicketMachine
|
13
|
13
|
{
|
14
|
14
|
// The price of a ticket from this machine.
|
15
|
15
|
private int price;
|
|
@@ -17,15 +17,17 @@ public class TicketMachine
|
17
|
17
|
private int balance;
|
18
|
18
|
// The total amount of money collected by this machine.
|
19
|
19
|
private int total;
|
|
20
|
+
|
|
21
|
+ private int status;
|
20
|
22
|
|
21
|
23
|
/**
|
22
|
24
|
* Create a machine that issues tickets of the given price.
|
23
|
25
|
* Note that the price must be greater than zero, and there
|
24
|
26
|
* are no checks to ensure this.
|
25
|
27
|
*/
|
26
|
|
- public TicketMachine(int ticketCost)
|
|
28
|
+ public TicketMachine()
|
27
|
29
|
{
|
28
|
|
- price = ticketCost;
|
|
30
|
+ price = 1000;
|
29
|
31
|
balance = 0;
|
30
|
32
|
total = 0;
|
31
|
33
|
}
|
|
@@ -75,4 +77,25 @@ public class TicketMachine
|
75
|
77
|
// Clear the balance.
|
76
|
78
|
balance = 0;
|
77
|
79
|
}
|
|
80
|
+
|
|
81
|
+ public void prompt()
|
|
82
|
+ {
|
|
83
|
+ System.out.println("Please insert the correct amount of money.");
|
|
84
|
+ }
|
|
85
|
+ public void showPrice()
|
|
86
|
+ {
|
|
87
|
+ System.out.println("The price of a ticket is " + price + " cents.");
|
|
88
|
+
|
78
|
89
|
}
|
|
90
|
+ public void empty()
|
|
91
|
+ {
|
|
92
|
+ total = total + balance;
|
|
93
|
+ balance = 0;
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ public void setPrice(int set)
|
|
97
|
+ {
|
|
98
|
+ price = set;
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ }
|