Ben Blinebury 6 лет назад
Родитель
Сommit
8c9e4f05dd
3 измененных файлов: 40 добавлений и 8 удалений
  1. 34
    2
      TicketMachine.java
  2. 3
    3
      bluej.pkg
  3. 3
    3
      package.bluej

+ 34
- 2
TicketMachine.java Просмотреть файл

@@ -23,9 +23,16 @@ public class TicketMachine
23 23
      * Note that the price must be greater than zero, and there
24 24
      * are no checks to ensure this.
25 25
      */
26
-    public TicketMachine(int ticketCost)
26
+    public TicketMachine()
27 27
     {
28
-        price = ticketCost;
28
+        price = 1000;
29
+        balance = 0;
30
+        total = 0;
31
+    }
32
+
33
+    public TicketMachine(int ticketPrice)
34
+    {
35
+        price = ticketPrice;
29 36
         balance = 0;
30 37
         total = 0;
31 38
     }
@@ -38,6 +45,18 @@ public class TicketMachine
38 45
         return price;
39 46
     }
40 47
 
48
+    public void discount(int amount) {
49
+        price -= amount;
50
+    }
51
+
52
+    public void setPrice(int ticketCost){
53
+        price = ticketCost;
54
+    }
55
+
56
+    public void empty() {
57
+        total = 0;   
58
+    }
59
+
41 60
     /**
42 61
      * Return the amount of money already inserted for the
43 62
      * next ticket.
@@ -55,6 +74,19 @@ public class TicketMachine
55 74
         balance = balance + amount;
56 75
     }
57 76
 
77
+    public int getTotal() 
78
+    {
79
+        return total;
80
+    }
81
+
82
+    public void showPrice() {
83
+        System.out.println("The price of a ticket is " + price + " cents.");   
84
+    }
85
+
86
+    public void prompt() {
87
+        System.out.println("Please insert the correct amount of money.");
88
+    }
89
+
58 90
     /**
59 91
      * Print a ticket.
60 92
      * Update the total collected and

+ 3
- 3
bluej.pkg Просмотреть файл

@@ -1,7 +1,7 @@
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
4
+editor.fx.0.x=640
5 5
 editor.fx.0.y=113
6 6
 objectbench.height=101
7 7
 objectbench.width=461
@@ -9,8 +9,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
13
-package.editor.y=119
12
+package.editor.x=629
13
+package.editor.y=47
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0

+ 3
- 3
package.bluej Просмотреть файл

@@ -1,7 +1,7 @@
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
4
+editor.fx.0.x=640
5 5
 editor.fx.0.y=113
6 6
 objectbench.height=101
7 7
 objectbench.width=461
@@ -9,8 +9,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
13
-package.editor.y=119
12
+package.editor.x=629
13
+package.editor.y=47
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0