|
@@ -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
|
+class TicketMachine
|
13
|
13
|
{
|
14
|
14
|
// The price of a ticket from this machine.
|
15
|
15
|
private int price;
|
|
@@ -23,11 +23,12 @@ public class TicketMachine
|
23
|
23
|
* Note that the price must be greater than zero, and there
|
24
|
24
|
* are no checks to ensure this.
|
25
|
25
|
*/
|
26
|
|
- public TicketMachine(int ticketCost)
|
|
26
|
+ public TicketMachine()
|
27
|
27
|
{
|
28
|
|
- price = ticketCost;
|
|
28
|
+ price = 1000;
|
29
|
29
|
balance = 0;
|
30
|
30
|
total = 0;
|
|
31
|
+ int status;
|
31
|
32
|
}
|
32
|
33
|
|
33
|
34
|
/**
|
|
@@ -75,4 +76,27 @@ public class TicketMachine
|
75
|
76
|
// Clear the balance.
|
76
|
77
|
balance = 0;
|
77
|
78
|
}
|
|
79
|
+
|
|
80
|
+ public int getTotal() {
|
|
81
|
+ return total;
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+ public void prompt() {
|
|
85
|
+ System.out.println("Please insert the correct amount of money.");
|
|
86
|
+ }
|
|
87
|
+
|
|
88
|
+ public void showPrice(){
|
|
89
|
+ System.out.println("The price of a ticket is " + price + " cents.");
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ public void empty(){
|
|
93
|
+ total = 0;
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ public void setPrice(int newPrice){
|
|
97
|
+ price = newPrice;
|
|
98
|
+ }
|
|
99
|
+
|
78
|
100
|
}
|
|
101
|
+
|
|
102
|
+
|