Bladeren bron

Naive Lab

Lewis Dominguez 6 jaren geleden
bovenliggende
commit
1faa1ae274
3 gewijzigde bestanden met toevoegingen van 91 en 19 verwijderingen
  1. 75
    3
      TicketMachine.java
  2. 8
    8
      bluej.pkg
  3. 8
    8
      package.bluej

+ 75
- 3
TicketMachine.java Bestand weergeven

@@ -17,18 +17,36 @@ 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
+    // The Status 
21
+    private int status;
22
+    
23
+    private int score = 100;
24
+    
25
+    private int discount = 20;
26
+    
27
+    private int saving;
28
+    
29
+    
20 30
 
21 31
     /**
22 32
      * Create a machine that issues tickets of the given price.
23 33
      * Note that the price must be greater than zero, and there
24 34
      * are no checks to ensure this.
25 35
      */
26
-    public TicketMachine(int ticketCost)
36
+    
37
+    public TicketMachine()
38
+    {
39
+      int price = 1000;
40
+      balance = 0;
41
+      total = 0;
42
+    } 
43
+
44
+    /*public TicketMachine(int ticketCost)
27 45
     {
28 46
         price = ticketCost;
29 47
         balance = 0;
30 48
         total = 0;
31
-    }
49
+    }*/
32 50
 
33 51
     /**
34 52
      * Return the price of a ticket.
@@ -42,7 +60,7 @@ public class TicketMachine
42 60
      * Return the amount of money already inserted for the
43 61
      * next ticket.
44 62
      */
45
-    public int getBalance()
63
+    public int getAmount()
46 64
     {
47 65
         return balance;
48 66
     }
@@ -54,6 +72,58 @@ public class TicketMachine
54 72
     {
55 73
         balance = balance + amount;
56 74
     }
75
+    
76
+    public int getTotal() {
77
+        return total;
78
+    }
79
+    
80
+    /**
81
+    * Increase score by the given number of points.
82
+    */
83
+    public void increase(int points)
84
+    {
85
+        score += points;
86
+    }
87
+    
88
+    /**
89
+    * Reduce price by the given amount.
90
+    */
91
+    public void discount(int amount)
92
+    {
93
+        price -= amount;
94
+    }
95
+    // Prompt method
96
+    public void prompt() 
97
+    {
98
+    System.out.println("Please insert the correct amount of money.");
99
+    }
100
+    // Show price method
101
+    public void showPrice() 
102
+    {
103
+    System.out.println("The price of a ticket is " + price + " cents.");
104
+    }
105
+    // Empty method
106
+    public void empty()
107
+    {
108
+        total = 0;
109
+    }
110
+    // Set Price method
111
+    public int setPrice(int newPrice) 
112
+    {
113
+        return newPrice;
114
+    }
115
+    
116
+    public void savings()
117
+    {
118
+        saving = price * discount;
119
+    }
120
+    
121
+    public int emptyMachine() {
122
+        return total;
123
+        
124
+        
125
+        
126
+    }
57 127
 
58 128
     /**
59 129
      * Print a ticket.
@@ -62,6 +132,8 @@ public class TicketMachine
62 132
      */
63 133
     public void printTicket()
64 134
     {
135
+        int amountLeftToPay = price - balance;
136
+        
65 137
         // Simulate the printing of a ticket.
66 138
         System.out.println("##################");
67 139
         System.out.println("# The BlueJ Line");

+ 8
- 8
bluej.pkg Bestand weergeven

@@ -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=671
5
+editor.fx.0.y=38
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=239
13
+package.editor.y=112
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0

+ 8
- 8
package.bluej Bestand weergeven

@@ -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=671
5
+editor.fx.0.y=38
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=239
13
+package.editor.y=112
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0