|
@@ -17,18 +17,36 @@ 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
|
+ // The Status
|
|
21
|
+ private int status;
|
|
22
|
+
|
|
23
|
+ private int score = 100;
|
|
24
|
+
|
|
25
|
+ private int discount = 20;
|
|
26
|
+
|
|
27
|
+ private int saving;
|
|
28
|
+
|
|
29
|
+
|
20
|
30
|
|
21
|
31
|
/**
|
22
|
32
|
* Create a machine that issues tickets of the given price.
|
23
|
33
|
* Note that the price must be greater than zero, and there
|
24
|
34
|
* are no checks to ensure this.
|
25
|
35
|
*/
|
26
|
|
- public TicketMachine(int ticketCost)
|
|
36
|
+
|
|
37
|
+ public TicketMachine()
|
|
38
|
+ {
|
|
39
|
+ int price = 1000;
|
|
40
|
+ balance = 0;
|
|
41
|
+ total = 0;
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ /*public TicketMachine(int ticketCost)
|
27
|
45
|
{
|
28
|
46
|
price = ticketCost;
|
29
|
47
|
balance = 0;
|
30
|
48
|
total = 0;
|
31
|
|
- }
|
|
49
|
+ }*/
|
32
|
50
|
|
33
|
51
|
/**
|
34
|
52
|
* Return the price of a ticket.
|
|
@@ -42,7 +60,7 @@ public class TicketMachine
|
42
|
60
|
* Return the amount of money already inserted for the
|
43
|
61
|
* next ticket.
|
44
|
62
|
*/
|
45
|
|
- public int getBalance()
|
|
63
|
+ public int getAmount()
|
46
|
64
|
{
|
47
|
65
|
return balance;
|
48
|
66
|
}
|
|
@@ -54,6 +72,58 @@ public class TicketMachine
|
54
|
72
|
{
|
55
|
73
|
balance = balance + amount;
|
56
|
74
|
}
|
|
75
|
+
|
|
76
|
+ public int getTotal() {
|
|
77
|
+ return total;
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ /**
|
|
81
|
+ * Increase score by the given number of points.
|
|
82
|
+ */
|
|
83
|
+ public void increase(int points)
|
|
84
|
+ {
|
|
85
|
+ score += points;
|
|
86
|
+ }
|
|
87
|
+
|
|
88
|
+ /**
|
|
89
|
+ * Reduce price by the given amount.
|
|
90
|
+ */
|
|
91
|
+ public void discount(int amount)
|
|
92
|
+ {
|
|
93
|
+ price -= amount;
|
|
94
|
+ }
|
|
95
|
+ // Prompt method
|
|
96
|
+ public void prompt()
|
|
97
|
+ {
|
|
98
|
+ System.out.println("Please insert the correct amount of money.");
|
|
99
|
+ }
|
|
100
|
+ // Show price method
|
|
101
|
+ public void showPrice()
|
|
102
|
+ {
|
|
103
|
+ System.out.println("The price of a ticket is " + price + " cents.");
|
|
104
|
+ }
|
|
105
|
+ // Empty method
|
|
106
|
+ public void empty()
|
|
107
|
+ {
|
|
108
|
+ total = 0;
|
|
109
|
+ }
|
|
110
|
+ // Set Price method
|
|
111
|
+ public int setPrice(int newPrice)
|
|
112
|
+ {
|
|
113
|
+ return newPrice;
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ public void savings()
|
|
117
|
+ {
|
|
118
|
+ saving = price * discount;
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ public int emptyMachine() {
|
|
122
|
+ return total;
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+ }
|
57
|
127
|
|
58
|
128
|
/**
|
59
|
129
|
* Print a ticket.
|
|
@@ -62,6 +132,8 @@ public class TicketMachine
|
62
|
132
|
*/
|
63
|
133
|
public void printTicket()
|
64
|
134
|
{
|
|
135
|
+ int amountLeftToPay = price - balance;
|
|
136
|
+
|
65
|
137
|
// Simulate the printing of a ticket.
|
66
|
138
|
System.out.println("##################");
|
67
|
139
|
System.out.println("# The BlueJ Line");
|