|
@@ -17,17 +17,20 @@ 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
|
+ // 2.15 exercise
|
|
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;
|
|
33
|
+
|
31
|
34
|
}
|
32
|
35
|
|
33
|
36
|
/**
|
|
@@ -46,6 +49,16 @@ public class TicketMachine
|
46
|
49
|
{
|
47
|
50
|
return balance;
|
48
|
51
|
}
|
|
52
|
+
|
|
53
|
+ public int getTotal()
|
|
54
|
+ {
|
|
55
|
+ return total;
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ public void setPrice(int ticketCost)
|
|
59
|
+ {
|
|
60
|
+ price = ticketCost;
|
|
61
|
+ }
|
49
|
62
|
|
50
|
63
|
/**
|
51
|
64
|
* Receive an amount of money in cents from a customer.
|
|
@@ -54,6 +67,21 @@ public class TicketMachine
|
54
|
67
|
{
|
55
|
68
|
balance = balance + amount;
|
56
|
69
|
}
|
|
70
|
+
|
|
71
|
+ public void prompt()
|
|
72
|
+ {
|
|
73
|
+ System.out.println("Please insert the correct amount of money.");
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ public void showPrice()
|
|
77
|
+ {
|
|
78
|
+ System.out.println("The price of a ticket is " + price + " cents.");
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ public void empty(int balance)
|
|
82
|
+ {
|
|
83
|
+ total = 0;
|
|
84
|
+ }
|
57
|
85
|
|
58
|
86
|
/**
|
59
|
87
|
* Print a ticket.
|