|
@@ -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;
|
|
@@ -17,6 +17,7 @@ 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
|
+ private int status;
|
20
|
21
|
|
21
|
22
|
/**
|
22
|
23
|
* Create a machine that issues tickets of the given price.
|
|
@@ -29,6 +30,18 @@ public class TicketMachine
|
29
|
30
|
balance = 0;
|
30
|
31
|
total = 0;
|
31
|
32
|
}
|
|
33
|
+
|
|
34
|
+ public void prompt()
|
|
35
|
+ {
|
|
36
|
+ System.out.println("Please insert the correct amount of money.");
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+ public void showPrice()
|
|
40
|
+ {
|
|
41
|
+ System.out.println("The price of a ticket is " + price + " cents.");
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+
|
32
|
45
|
|
33
|
46
|
/**
|
34
|
47
|
* Return the price of a ticket.
|
|
@@ -46,7 +59,7 @@ public class TicketMachine
|
46
|
59
|
{
|
47
|
60
|
return balance;
|
48
|
61
|
}
|
49
|
|
-
|
|
62
|
+
|
50
|
63
|
/**
|
51
|
64
|
* Receive an amount of money in cents from a customer.
|
52
|
65
|
*/
|
|
@@ -55,6 +68,11 @@ public class TicketMachine
|
55
|
68
|
balance = balance + amount;
|
56
|
69
|
}
|
57
|
70
|
|
|
71
|
+ public int getTotal()
|
|
72
|
+ {
|
|
73
|
+ return total;
|
|
74
|
+ }
|
|
75
|
+
|
58
|
76
|
/**
|
59
|
77
|
* Print a ticket.
|
60
|
78
|
* Update the total collected and
|