|
@@ -1,3 +1,5 @@
|
|
1
|
+package NaiveTicket;
|
|
2
|
+
|
1
|
3
|
/**
|
2
|
4
|
* TicketMachine models a naive ticket machine that issues
|
3
|
5
|
* flat-fare tickets.
|
|
@@ -9,7 +11,7 @@
|
9
|
11
|
* @author David J. Barnes and Michael Kolling
|
10
|
12
|
* @version 2008.03.30
|
11
|
13
|
*/
|
12
|
|
-public class TicketMachine
|
|
14
|
+ class TicketMachine
|
13
|
15
|
{
|
14
|
16
|
// The price of a ticket from this machine.
|
15
|
17
|
private int price;
|
|
@@ -17,19 +19,41 @@ public class TicketMachine
|
17
|
19
|
private int balance;
|
18
|
20
|
// The total amount of money collected by this machine.
|
19
|
21
|
private int total;
|
|
22
|
+ // The status of the ticket machine
|
|
23
|
+ private int status;
|
20
|
24
|
|
21
|
25
|
/**
|
22
|
26
|
* Create a machine that issues tickets of the given price.
|
23
|
27
|
* Note that the price must be greater than zero, and there
|
24
|
28
|
* are no checks to ensure this.
|
25
|
29
|
*/
|
26
|
|
- public TicketMachine(int ticketCost)
|
|
30
|
+ public TicketMachine()
|
27
|
31
|
{
|
28
|
|
- price = ticketCost;
|
|
32
|
+ price = 1000;
|
29
|
33
|
balance = 0;
|
30
|
34
|
total = 0;
|
31
|
35
|
}
|
32
|
|
-
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+ public void empty ()
|
|
39
|
+ {
|
|
40
|
+ total = 0;
|
|
41
|
+ }
|
|
42
|
+ //Money prompt
|
|
43
|
+ public void prompt ()
|
|
44
|
+ {
|
|
45
|
+ System.out.println("Please insert the correct amount of money");
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ //show price prompt
|
|
49
|
+ public void showPrice () {
|
|
50
|
+ System.out.println("The price of a ticket is " + price + " cents");
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ public void setPrice (int ticketCost)
|
|
54
|
+ {
|
|
55
|
+ ticketCost = price;
|
|
56
|
+ }
|
33
|
57
|
/**
|
34
|
58
|
* Return the price of a ticket.
|
35
|
59
|
*/
|