Browse Source

Curtis Cook's Naive Ticket Lab

Curtis Cook 6 years ago
parent
commit
a7ceb3f255
4 changed files with 68 additions and 13 deletions
  1. BIN
      .DS_Store
  2. 56
    1
      TicketMachine.java
  3. 6
    6
      bluej.pkg
  4. 6
    6
      package.bluej

BIN
.DS_Store View File


+ 56
- 1
TicketMachine.java View File

17
     private int balance;
17
     private int balance;
18
     // The total amount of money collected by this machine.
18
     // The total amount of money collected by this machine.
19
     private int total;
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
      * Create a machine that issues tickets of the given price.
32
      * Create a machine that issues tickets of the given price.
23
      * Note that the price must be greater than zero, and there
33
      * Note that the price must be greater than zero, and there
37
     {
47
     {
38
         return price;
48
         return price;
39
     }
49
     }
50
+    
51
+    public void setPrice(int ticketCost) {
52
+        price = ticketCost;
53
+    }
40
 
54
 
41
     /**
55
     /**
42
      * Return the amount of money already inserted for the
56
      * Return the amount of money already inserted for the
46
     {
60
     {
47
         return balance;
61
         return balance;
48
     }
62
     }
63
+       
64
+    public int getTotal() {
65
+        return total;
66
+    }
49
 
67
 
50
     /**
68
     /**
51
      * Receive an amount of money in cents from a customer.
69
      * Receive an amount of money in cents from a customer.
54
     {
72
     {
55
         balance = balance + amount;
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
      * Print a ticket.
103
      * Print a ticket.
60
      * Update the total collected and
104
      * Update the total collected and
74
         total = total + balance;
118
         total = total + balance;
75
         // Clear the balance.
119
         // Clear the balance.
76
         balance = 0;
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 View File

1
 #BlueJ package file
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
 objectbench.height=101
6
 objectbench.height=101
7
-objectbench.width=461
7
+objectbench.width=776
8
 package.divider.horizontal=0.6
8
 package.divider.horizontal=0.6
9
 package.divider.vertical=0.8007380073800738
9
 package.divider.vertical=0.8007380073800738
10
 package.editor.height=427
10
 package.editor.height=427
11
 package.editor.width=674
11
 package.editor.width=674
12
-package.editor.x=1067
12
+package.editor.x=640
13
 package.editor.y=119
13
 package.editor.y=119
14
 package.frame.height=600
14
 package.frame.height=600
15
 package.frame.width=800
15
 package.frame.width=800

+ 6
- 6
package.bluej View File

1
 #BlueJ package file
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
 objectbench.height=101
6
 objectbench.height=101
7
-objectbench.width=461
7
+objectbench.width=776
8
 package.divider.horizontal=0.6
8
 package.divider.horizontal=0.6
9
 package.divider.vertical=0.8007380073800738
9
 package.divider.vertical=0.8007380073800738
10
 package.editor.height=427
10
 package.editor.height=427
11
 package.editor.width=674
11
 package.editor.width=674
12
-package.editor.x=1067
12
+package.editor.x=640
13
 package.editor.y=119
13
 package.editor.y=119
14
 package.frame.height=600
14
 package.frame.height=600
15
 package.frame.width=800
15
 package.frame.width=800