|
@@ -23,13 +23,25 @@ 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
|
+
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ public void prompt()
|
|
35
|
+ {
|
|
36
|
+ System.out.println("Please insert the correct amount of money.");
|
31
|
37
|
}
|
32
|
38
|
|
|
39
|
+
|
|
40
|
+ public void showPrice()
|
|
41
|
+ {
|
|
42
|
+ System.out.println("The price of a ticket is" + price + "cents.");
|
|
43
|
+ }
|
|
44
|
+
|
33
|
45
|
/**
|
34
|
46
|
* Return the price of a ticket.
|
35
|
47
|
*/
|
|
@@ -46,6 +58,15 @@ public class TicketMachine
|
46
|
58
|
{
|
47
|
59
|
return balance;
|
48
|
60
|
}
|
|
61
|
+
|
|
62
|
+ public int setPrice(int setPrice){
|
|
63
|
+ price = setPrice;
|
|
64
|
+ {
|
|
65
|
+ return price;
|
|
66
|
+
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ }
|
49
|
70
|
|
50
|
71
|
/**
|
51
|
72
|
* Receive an amount of money in cents from a customer.
|
|
@@ -54,6 +75,12 @@ public class TicketMachine
|
54
|
75
|
{
|
55
|
76
|
balance = balance + amount;
|
56
|
77
|
}
|
|
78
|
+
|
|
79
|
+ //empty machine
|
|
80
|
+ public void empty(){
|
|
81
|
+ balance = 0;
|
|
82
|
+
|
|
83
|
+ }
|
57
|
84
|
|
58
|
85
|
/**
|
59
|
86
|
* Print a ticket.
|