Tennessee Gibbs 6 年之前
父節點
當前提交
8c814168aa
共有 7 個檔案被更改,包括 37 行新增10 行删除
  1. 0
    0
      README.TXT
  2. 0
    0
      README.md
  3. 29
    2
      TicketMachine.java
  4. 4
    4
      bluej.pkg
  5. 0
    0
      bluej.pkh
  6. 0
    0
      doc/BlueJ-objects-first-ch2.pdf
  7. 4
    4
      package.bluej

+ 0
- 0
README.TXT 查看文件


+ 0
- 0
README.md 查看文件


+ 29
- 2
TicketMachine.java 查看文件

@@ -23,13 +23,25 @@ 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 29
         balance = 0;
30 30
         total = 0;
31
+       
32
+    }
33
+    
34
+    public void prompt()
35
+    {
36
+    System.out.println("Please insert the correct amount of money.");
31 37
     }
32 38
 
39
+    
40
+    public void showPrice()
41
+    {
42
+    System.out.println("The price of a ticket is" + price + "cents.");
43
+    }
44
+    
33 45
     /**
34 46
      * Return the price of a ticket.
35 47
      */
@@ -46,6 +58,15 @@ public class TicketMachine
46 58
     {
47 59
         return balance;
48 60
     }
61
+    
62
+    public int setPrice(int setPrice){
63
+        price = setPrice;
64
+        {
65
+            return price;
66
+        
67
+        }
68
+  
69
+    }
49 70
 
50 71
     /**
51 72
      * Receive an amount of money in cents from a customer.
@@ -54,6 +75,12 @@ public class TicketMachine
54 75
     {
55 76
         balance = balance + amount;
56 77
     }
78
+    
79
+    //empty machine
80
+    public void empty(){
81
+        balance = 0;
82
+    
83
+    }
57 84
 
58 85
     /**
59 86
      * Print a ticket.

+ 4
- 4
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
4
+editor.fx.0.x=320
5
+editor.fx.0.y=57
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=461
13
+package.editor.y=238
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0

+ 0
- 0
bluej.pkh 查看文件


+ 0
- 0
doc/BlueJ-objects-first-ch2.pdf 查看文件


+ 4
- 4
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
4
+editor.fx.0.x=320
5
+editor.fx.0.y=57
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=461
13
+package.editor.y=238
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0