Explorar el Código

Curtis Cook's Naive Ticket Lab

Curtis Cook hace 6 años
padre
commit
a7ceb3f255
Se han modificado 4 ficheros con 68 adiciones y 13 borrados
  1. BIN
      .DS_Store
  2. 56
    1
      TicketMachine.java
  3. 6
    6
      bluej.pkg
  4. 6
    6
      package.bluej

BIN
.DS_Store Ver fichero


+ 56
- 1
TicketMachine.java Ver fichero

@@ -17,7 +17,17 @@ 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
 
25
+    public TicketMachine() {
26
+        price = 1000;
27
+        balance = 0;
28
+        total = 0;
29
+    }
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
@@ -37,6 +47,10 @@ public class TicketMachine
37 47
     {
38 48
         return price;
39 49
     }
50
+    
51
+    public void setPrice(int ticketCost) {
52
+        price = ticketCost;
53
+    }
40 54
 
41 55
     /**
42 56
      * Return the amount of money already inserted for the
@@ -46,6 +60,10 @@ public class TicketMachine
46 60
     {
47 61
         return balance;
48 62
     }
63
+       
64
+    public int getTotal() {
65
+        return total;
66
+    }
49 67
 
50 68
     /**
51 69
      * Receive an amount of money in cents from a customer.
@@ -54,7 +72,33 @@ public class TicketMachine
54 72
     {
55 73
         balance = balance + amount;
56 74
     }
57
-
75
+    
76
+    /**
77
+     * Increase score by the give number of points.
78
+     */
79
+    public void increase(int points) {
80
+        score += points;
81
+    }
82
+    
83
+    /**
84
+     * Reduce price by the given amount.
85
+     */
86
+    public void discount(int amount) {
87
+        price -= amount;
88
+    }
89
+    
90
+    public void prompt() {
91
+        System.out.println("Please insert the correct amount of money.");
92
+    }
93
+    
94
+    public void showPrice() {
95
+        System.out.println("The price of a ticket is " + price + " cents.");
96
+    }    
97
+    
98
+    public void empty() {
99
+        total = 0;
100
+    }
101
+    
58 102
     /**
59 103
      * Print a ticket.
60 104
      * Update the total collected and
@@ -74,5 +118,16 @@ public class TicketMachine
74 118
         total = total + balance;
75 119
         // Clear the balance.
76 120
         balance = 0;
121
+    }        
122
+    
123
+    public class Student {
124
+        
125
+    }
126
+    
127
+    public class LabClass {
128
+        
77 129
     }
78 130
 }
131
+
132
+
133
+

+ 6
- 6
bluej.pkg Ver fichero

@@ -1,15 +1,15 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
3
-editor.fx.0.width=800
4
-editor.fx.0.x=709
5
-editor.fx.0.y=113
2
+editor.fx.0.height=0
3
+editor.fx.0.width=0
4
+editor.fx.0.x=0
5
+editor.fx.0.y=0
6 6
 objectbench.height=101
7
-objectbench.width=461
7
+objectbench.width=776
8 8
 package.divider.horizontal=0.6
9 9
 package.divider.vertical=0.8007380073800738
10 10
 package.editor.height=427
11 11
 package.editor.width=674
12
-package.editor.x=1067
12
+package.editor.x=640
13 13
 package.editor.y=119
14 14
 package.frame.height=600
15 15
 package.frame.width=800

+ 6
- 6
package.bluej Ver fichero

@@ -1,15 +1,15 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
3
-editor.fx.0.width=800
4
-editor.fx.0.x=709
5
-editor.fx.0.y=113
2
+editor.fx.0.height=0
3
+editor.fx.0.width=0
4
+editor.fx.0.x=0
5
+editor.fx.0.y=0
6 6
 objectbench.height=101
7
-objectbench.width=461
7
+objectbench.width=776
8 8
 package.divider.horizontal=0.6
9 9
 package.divider.vertical=0.8007380073800738
10 10
 package.editor.height=427
11 11
 package.editor.width=674
12
-package.editor.x=1067
12
+package.editor.x=640
13 13
 package.editor.y=119
14 14
 package.frame.height=600
15 15
 package.frame.width=800