|
@@ -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,19 +17,28 @@ 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;
|
|
21
|
+
|
|
22
|
+ public class Student {
|
|
23
|
+
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ public class LabClass{
|
|
27
|
+
|
|
28
|
+ }
|
20
|
29
|
|
21
|
30
|
/**
|
22
|
31
|
* Create a machine that issues tickets of the given price.
|
23
|
32
|
* Note that the price must be greater than zero, and there
|
24
|
33
|
* are no checks to ensure this.
|
25
|
34
|
*/
|
26
|
|
- public TicketMachine(int ticketCost)
|
|
35
|
+ public TicketMachine()
|
27
|
36
|
{
|
28
|
|
- price = ticketCost;
|
|
37
|
+ price = 1000;
|
29
|
38
|
balance = 0;
|
30
|
39
|
total = 0;
|
31
|
40
|
}
|
32
|
|
-
|
|
41
|
+
|
33
|
42
|
/**
|
34
|
43
|
* Return the price of a ticket.
|
35
|
44
|
*/
|
|
@@ -38,6 +47,25 @@ public class TicketMachine
|
38
|
47
|
return price;
|
39
|
48
|
}
|
40
|
49
|
|
|
50
|
+ public void setPrice(int ticketCost){
|
|
51
|
+ ticketCost = price;
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ public void discount(int amount){
|
|
55
|
+ amount = price - amount;
|
|
56
|
+
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ public void prompt(){
|
|
60
|
+ System.out.println("Please insert correct amount of money");
|
|
61
|
+
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ public void showPrice(){
|
|
65
|
+ System.out.println("The price of the ticket is " + price + " cents");
|
|
66
|
+
|
|
67
|
+ }
|
|
68
|
+
|
41
|
69
|
/**
|
42
|
70
|
* Return the amount of money already inserted for the
|
43
|
71
|
* next ticket.
|
|
@@ -47,6 +75,10 @@ public class TicketMachine
|
47
|
75
|
return balance;
|
48
|
76
|
}
|
49
|
77
|
|
|
78
|
+ public int getTotal() {
|
|
79
|
+ return total;
|
|
80
|
+ }
|
|
81
|
+
|
50
|
82
|
/**
|
51
|
83
|
* Receive an amount of money in cents from a customer.
|
52
|
84
|
*/
|
|
@@ -54,7 +86,9 @@ public class TicketMachine
|
54
|
86
|
{
|
55
|
87
|
balance = balance + amount;
|
56
|
88
|
}
|
57
|
|
-
|
|
89
|
+ public void empty(){
|
|
90
|
+ total = 0;
|
|
91
|
+ }
|
58
|
92
|
/**
|
59
|
93
|
* Print a ticket.
|
60
|
94
|
* Update the total collected and
|
|
@@ -67,6 +101,8 @@ public class TicketMachine
|
67
|
101
|
System.out.println("# The BlueJ Line");
|
68
|
102
|
System.out.println("# Ticket");
|
69
|
103
|
System.out.println("# " + price + " cents.");
|
|
104
|
+ System.out.println("# " + "price" + " cents.");
|
|
105
|
+ System.out.println("# price cents.");
|
70
|
106
|
System.out.println("##################");
|
71
|
107
|
System.out.println();
|
72
|
108
|
|