|
@@ -23,9 +23,16 @@ 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
|
+ balance = 0;
|
|
30
|
+ total = 0;
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ public TicketMachine(int ticketPrice)
|
|
34
|
+ {
|
|
35
|
+ price = ticketPrice;
|
29
|
36
|
balance = 0;
|
30
|
37
|
total = 0;
|
31
|
38
|
}
|
|
@@ -38,6 +45,18 @@ public class TicketMachine
|
38
|
45
|
return price;
|
39
|
46
|
}
|
40
|
47
|
|
|
48
|
+ public void discount(int amount) {
|
|
49
|
+ price -= amount;
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ public void setPrice(int ticketCost){
|
|
53
|
+ price = ticketCost;
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ public void empty() {
|
|
57
|
+ total = 0;
|
|
58
|
+ }
|
|
59
|
+
|
41
|
60
|
/**
|
42
|
61
|
* Return the amount of money already inserted for the
|
43
|
62
|
* next ticket.
|
|
@@ -55,6 +74,19 @@ public class TicketMachine
|
55
|
74
|
balance = balance + amount;
|
56
|
75
|
}
|
57
|
76
|
|
|
77
|
+ public int getTotal()
|
|
78
|
+ {
|
|
79
|
+ return total;
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ public void showPrice() {
|
|
83
|
+ System.out.println("The price of a ticket is " + price + " cents.");
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ public void prompt() {
|
|
87
|
+ System.out.println("Please insert the correct amount of money.");
|
|
88
|
+ }
|
|
89
|
+
|
58
|
90
|
/**
|
59
|
91
|
* Print a ticket.
|
60
|
92
|
* Update the total collected and
|