Kate Moore 6 gadus atpakaļ
vecāks
revīzija
9add2f669d
3 mainītis faili ar 54 papildinājumiem un 26 dzēšanām
  1. 30
    2
      TicketMachine.java
  2. 12
    12
      bluej.pkg
  3. 12
    12
      package.bluej

+ 30
- 2
TicketMachine.java Parādīt failu

@@ -17,17 +17,20 @@ 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
+    // 2.15 exercise
21
+    private int status;
20 22
 
21 23
     /**
22 24
      * Create a machine that issues tickets of the given price.
23 25
      * Note that the price must be greater than zero, and there
24 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 31
         balance = 0;
30 32
         total = 0;
33
+        
31 34
     }
32 35
 
33 36
     /**
@@ -46,6 +49,16 @@ public class TicketMachine
46 49
     {
47 50
         return balance;
48 51
     }
52
+    
53
+    public int getTotal()
54
+    {
55
+        return total;
56
+    }
57
+    
58
+    public void setPrice(int ticketCost)
59
+    {
60
+        price = ticketCost;
61
+    }
49 62
 
50 63
     /**
51 64
      * Receive an amount of money in cents from a customer.
@@ -54,6 +67,21 @@ public class TicketMachine
54 67
     {
55 68
         balance = balance + amount;
56 69
     }
70
+    
71
+    public void prompt()
72
+    {
73
+        System.out.println("Please insert the correct amount of money.");
74
+    }
75
+    
76
+    public void showPrice()
77
+    {
78
+        System.out.println("The price of a ticket is " + price + " cents.");
79
+    }
80
+    
81
+    public void empty(int balance)
82
+    {
83
+        total = 0;
84
+    }
57 85
 
58 86
     /**
59 87
      * Print a ticket.

+ 12
- 12
bluej.pkg Parādīt failu

@@ -1,18 +1,18 @@
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=716
3
+editor.fx.0.width=794
4
+editor.fx.0.x=485
5
+editor.fx.0.y=23
6 6
 objectbench.height=101
7
-objectbench.width=461
7
+objectbench.width=455
8 8
 package.divider.horizontal=0.6
9
-package.divider.vertical=0.8007380073800738
10
-package.editor.height=427
11
-package.editor.width=674
12
-package.editor.x=1067
13
-package.editor.y=119
14
-package.frame.height=600
15
-package.frame.width=800
9
+package.divider.vertical=0.7652173913043478
10
+package.editor.height=345
11
+package.editor.width=353
12
+package.editor.x=5
13
+package.editor.y=23
14
+package.frame.height=518
15
+package.frame.width=479
16 16
 package.numDependencies=0
17 17
 package.numTargets=1
18 18
 package.showExtends=true

+ 12
- 12
package.bluej Parādīt failu

@@ -1,18 +1,18 @@
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=716
3
+editor.fx.0.width=794
4
+editor.fx.0.x=485
5
+editor.fx.0.y=23
6 6
 objectbench.height=101
7
-objectbench.width=461
7
+objectbench.width=455
8 8
 package.divider.horizontal=0.6
9
-package.divider.vertical=0.8007380073800738
10
-package.editor.height=427
11
-package.editor.width=674
12
-package.editor.x=1067
13
-package.editor.y=119
14
-package.frame.height=600
15
-package.frame.width=800
9
+package.divider.vertical=0.7652173913043478
10
+package.editor.height=345
11
+package.editor.width=353
12
+package.editor.x=5
13
+package.editor.y=23
14
+package.frame.height=518
15
+package.frame.width=479
16 16
 package.numDependencies=0
17 17
 package.numTargets=1
18 18
 package.showExtends=true