Chad пре 6 година
родитељ
комит
45f1c1ab38
4 измењених фајлова са 66 додато и 16 уклоњено
  1. BIN
      .DS_Store
  2. 50
    0
      TicketMachine.java
  3. 8
    8
      bluej.pkg
  4. 8
    8
      package.bluej

+ 50
- 0
TicketMachine.java Прегледај датотеку

@@ -19,6 +19,18 @@ public class TicketMachine
19 19
     private int total;
20 20
 
21 21
     /**
22
+     * Create a machine that issues tickets of price = 1000.
23
+     * Note that the price must be greater than zero, and there
24
+     * are no checks to ensure this.
25
+     */
26
+    public TicketMachine()
27
+    {
28
+        price = 1000;
29
+        balance = 0;
30
+        total = 0;
31
+    }
32
+    
33
+    /**
22 34
      * Create a machine that issues tickets of the given price.
23 35
      * Note that the price must be greater than zero, and there
24 36
      * are no checks to ensure this.
@@ -30,6 +42,11 @@ public class TicketMachine
30 42
         total = 0;
31 43
     }
32 44
 
45
+    public void setPrice(int ticketCost)
46
+    {
47
+        price = ticketCost;
48
+    }
49
+    
33 50
     /**
34 51
      * Return the price of a ticket.
35 52
      */
@@ -48,12 +65,45 @@ public class TicketMachine
48 65
     }
49 66
 
50 67
     /**
68
+     * Return the amount of money already inserted for the
69
+     * next ticket.
70
+     */
71
+    public int getTotal()
72
+    {
73
+        return total;
74
+    }
75
+    
76
+    /**
51 77
      * Receive an amount of money in cents from a customer.
52 78
      */
53 79
     public void insertMoney(int amount)
54 80
     {
55 81
         balance = balance + amount;
56 82
     }
83
+    
84
+    /**
85
+     * Print a message prompting the user to insert correct amount
86
+     */
87
+    public void prompt()
88
+    {
89
+        System.out.println("Please insert the correct amount of money.");
90
+    }
91
+    
92
+    /**
93
+     * Print a message letting the user know the ticket amount
94
+     */
95
+    public void showPrice()
96
+    {
97
+        System.out.println("The price of a ticket is " + price + " cents.");
98
+    }
99
+    
100
+    /**
101
+     * Print a message letting the user know the ticket amount
102
+     */
103
+    public void empty()
104
+    {
105
+        total=0;
106
+    }
57 107
 
58 108
     /**
59 109
      * Print a ticket.

+ 8
- 8
bluej.pkg Прегледај датотеку

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2 2
 editor.fx.0.height=722
3 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=2248
5
+editor.fx.0.y=102
6
+objectbench.height=164
7
+objectbench.width=776
8 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 11
 package.editor.width=674
12
-package.editor.x=1067
13
-package.editor.y=119
12
+package.editor.x=1447
13
+package.editor.y=90
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0

+ 8
- 8
package.bluej Прегледај датотеку

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2 2
 editor.fx.0.height=722
3 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=2248
5
+editor.fx.0.y=102
6
+objectbench.height=164
7
+objectbench.width=776
8 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 11
 package.editor.width=674
12
-package.editor.x=1067
13
-package.editor.y=119
12
+package.editor.x=1447
13
+package.editor.y=90
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0