瀏覽代碼

changes complete

Donna Jacobs 6 年之前
父節點
當前提交
50b2bd2519
共有 5 個文件被更改,包括 39 次插入14 次删除
  1. 二進制
      .DS_Store
  2. 29
    4
      TicketMachine.java
  3. 5
    5
      bluej.pkg
  4. 二進制
      doc/.DS_Store
  5. 5
    5
      package.bluej

二進制
.DS_Store 查看文件


+ 29
- 4
TicketMachine.java 查看文件

@@ -9,7 +9,7 @@
9 9
  * @author David J. Barnes and Michael Kolling
10 10
  * @version 2008.03.30
11 11
  */
12
-public class TicketMachine
12
+ public class TicketMachine
13 13
 {
14 14
     // The price of a ticket from this machine.
15 15
     private int price;
@@ -25,9 +25,18 @@ public class TicketMachine
25 25
      */
26 26
     public TicketMachine(int ticketCost)
27 27
     {
28
-        price = ticketCost;
29
-        balance = 0;
30
-        total = 0;
28
+      price = ticketCost;
29
+      balance = 0;
30
+      total = 0;
31
+        
32
+    }
33
+    
34
+    public TicketMachine()
35
+    {
36
+      price = 700;
37
+      balance = 0;
38
+      total = 0;
39
+        
31 40
     }
32 41
 
33 42
     /**
@@ -37,6 +46,10 @@ public class TicketMachine
37 46
     {
38 47
         return price;
39 48
     }
49
+    
50
+    public void setPrice(int newPrice) {
51
+        price = newPrice;
52
+    }
40 53
 
41 54
     /**
42 55
      * Return the amount of money already inserted for the
@@ -46,6 +59,14 @@ public class TicketMachine
46 59
     {
47 60
         return balance;
48 61
     }
62
+    
63
+    public void prompt() {
64
+        System.out.println("Please insert the correct amount of money");
65
+    }
66
+    
67
+    public void showPrice() {
68
+        System.out.println("The price of a ticket is " + price + " cents.");
69
+    }
49 70
 
50 71
     /**
51 72
      * Receive an amount of money in cents from a customer.
@@ -54,6 +75,10 @@ public class TicketMachine
54 75
     {
55 76
         balance = balance + amount;
56 77
     }
78
+    
79
+    public void empty() {
80
+        total = 0;
81
+    }
57 82
 
58 83
     /**
59 84
      * Print a ticket.

+ 5
- 5
bluej.pkg 查看文件

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
2
+editor.fx.0.height=709
3 3
 editor.fx.0.width=800
4
-editor.fx.0.x=709
5
-editor.fx.0.y=113
4
+editor.fx.0.x=240
5
+editor.fx.0.y=23
6 6
 objectbench.height=101
7 7
 objectbench.width=461
8 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=239
13
+package.editor.y=61
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0

二進制
doc/.DS_Store 查看文件


+ 5
- 5
package.bluej 查看文件

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
2
+editor.fx.0.height=709
3 3
 editor.fx.0.width=800
4
-editor.fx.0.x=709
5
-editor.fx.0.y=113
4
+editor.fx.0.x=240
5
+editor.fx.0.y=23
6 6
 objectbench.height=101
7 7
 objectbench.width=461
8 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=239
13
+package.editor.y=61
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0