Jason Gibbs hace 6 años
padre
commit
0b4406d7de
Se han modificado 1 ficheros con 37 adiciones y 1 borrados
  1. 37
    1
      TicketMachine.java

+ 37
- 1
TicketMachine.java Ver fichero

@@ -17,6 +17,10 @@ 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
+    
21
+    private int status;
22
+    
23
+    private int score;
20 24
 
21 25
     /**
22 26
      * Create a machine that issues tickets of the given price.
@@ -29,6 +33,13 @@ public class TicketMachine
29 33
         balance = 0;
30 34
         total = 0;
31 35
     }
36
+    
37
+    public TicketMachine()
38
+    {
39
+        price = 500;
40
+        balance = 0;
41
+        total = 0;
42
+    }
32 43
 
33 44
     /**
34 45
      * Return the price of a ticket.
@@ -46,7 +57,28 @@ public class TicketMachine
46 57
     {
47 58
         return balance;
48 59
     }
49
-
60
+    
61
+    // Returns the total amount of money inserted
62
+    public int getTotal() {
63
+        return total;   
64
+    }    
65
+    // Sets the price via the ticketCost parameter/argument
66
+    public void setPrice(int ticketCost) {
67
+        price = ticketCost;
68
+    }    
69
+    // increase score by the given number of points
70
+    public void increase(int points) {
71
+        score += points;
72
+    }
73
+    // prompts the user to insert the correct amount of money
74
+    public void prompt() {
75
+        System.out.println("Please insert the correct amount of money.");
76
+    }
77
+    // Displays the price of a ticket
78
+    public void showPrice() {
79
+        System.out.println("The price of a ticket is " + price + " cents" );
80
+    }
81
+    
50 82
     /**
51 83
      * Receive an amount of money in cents from a customer.
52 84
      */
@@ -75,4 +107,8 @@ public class TicketMachine
75 107
         // Clear the balance.
76 108
         balance = 0;
77 109
     }
110
+    // removes all money from the machine
111
+    public void empty() {
112
+        total = 0;
113
+    }
78 114
 }