Browse Source

Randall G Naive complete

Randall Gibson Jr 6 years ago
parent
commit
1dc5940abd
4 changed files with 44 additions and 21 deletions
  1. BIN
      .DS_Store
  2. 26
    3
      TicketMachine.java
  3. 9
    9
      bluej.pkg
  4. 9
    9
      package.bluej

BIN
.DS_Store View File


+ 26
- 3
TicketMachine.java View File

9
  * @author David J. Barnes and Michael Kolling
9
  * @author David J. Barnes and Michael Kolling
10
  * @version 2008.03.30
10
  * @version 2008.03.30
11
  */
11
  */
12
-public class TicketMachine
12
+ public class TicketMachine
13
 {
13
 {
14
     // The price of a ticket from this machine.
14
     // The price of a ticket from this machine.
15
     private int price;
15
     private int price;
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;
20
 
22
 
21
     /**
23
     /**
22
      * Create a machine that issues tickets of the given price.
24
      * Create a machine that issues tickets of the given price.
23
      * Note that the price must be greater than zero, and there
25
      * Note that the price must be greater than zero, and there
24
      * are no checks to ensure this.
26
      * are no checks to ensure this.
25
      */
27
      */
26
-    public TicketMachine(int ticketCost)
28
+    public TicketMachine()
27
     {
29
     {
28
-        price = ticketCost;
30
+        price = 1000;
29
         balance = 0;
31
         balance = 0;
30
         total = 0;
32
         total = 0;
31
     }
33
     }
75
         // Clear the balance.
77
         // Clear the balance.
76
         balance = 0;
78
         balance = 0;
77
     }
79
     }
80
+    
81
+    public void prompt()
82
+    {
83
+        System.out.println("Please insert the correct amount of money.");
84
+    }
85
+    public void showPrice()
86
+    {
87
+        System.out.println("The price of a ticket is " + price + " cents.");
88
+        
78
 }
89
 }
90
+    public void empty()
91
+    {
92
+        total = total + balance;
93
+        balance = 0;
94
+    }
95
+    
96
+    public void setPrice(int set)
97
+    {
98
+        price = set;
99
+    }
100
+        
101
+    }

+ 9
- 9
bluej.pkg View File

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

+ 9
- 9
package.bluej View File

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