Mexi 6 년 전
부모
커밋
80bbcc140e
4개의 변경된 파일84개의 추가작업 그리고 40개의 파일을 삭제
  1. 9
    0
      Pet.java
  2. 43
    22
      TicketMachine.java
  3. 16
    9
      bluej.pkg
  4. 16
    9
      package.bluej

+ 9
- 0
Pet.java 파일 보기

@@ -0,0 +1,9 @@
1
+
2
+public class Pet
3
+{
4
+   private String name; 
5
+   public Pet(String name){
6
+    this.name = name;
7
+    }
8
+    
9
+}

+ 43
- 22
TicketMachine.java 파일 보기

@@ -1,38 +1,34 @@
1
-/**
2
- * TicketMachine models a naive ticket machine that issues
3
- * flat-fare tickets.
4
- * The price of a ticket is specified via the constructor.
5
- * It is a naive machine in the sense that it trusts its users
6
- * to insert enough money before trying to print a ticket.
7
- * It also assumes that users enter sensible amounts.
8
- *
9
- * @author David J. Barnes and Michael Kolling
10
- * @version 2008.03.30
11
- */
1
+
12 2
 public class TicketMachine
13 3
 {
14
-    // The price of a ticket from this machine.
4
+    
15 5
     private int price;
16
-    // The amount of money entered by a customer so far.
6
+    
17 7
     private int balance;
18
-    // The total amount of money collected by this machine.
8
+    
19 9
     private int total;
20
-
10
+    
11
+    private int score;
21 12
     /**
22 13
      * Create a machine that issues tickets of the given price.
23 14
      * Note that the price must be greater than zero, and there
24 15
      * are no checks to ensure this.
25 16
      */
26
-    public TicketMachine(int ticketCost)
17
+    public TicketMachine()
27 18
     {
28
-        price = ticketCost;
19
+        price = 1000;
29 20
         balance = 0;
30 21
         total = 0;
31 22
     }
32
-
33
-    /**
34
-     * Return the price of a ticket.
35
-     */
23
+    
24
+    public TicketMachine(int ticketCost){}
25
+    
26
+    
27
+    public void setPrie(int ticketCost){
28
+       price = ticketCost;
29
+    }
30
+    
31
+   
36 32
     public int getPrice()
37 33
     {
38 34
         return price;
@@ -47,6 +43,23 @@ public class TicketMachine
47 43
         return balance;
48 44
     }
49 45
 
46
+    public void increase(int points){
47
+        score = score + points;
48
+    }
49
+    
50
+    public void discount(int amount){
51
+    
52
+        price = price - amount;
53
+    }
54
+    
55
+    public void promot(){
56
+        System.out.println("Please insert the correct amount of money.");
57
+    }
58
+    
59
+    public void showPrice(){
60
+        System.out.println("The price of a ticke is" + price + "cents");
61
+    }
62
+    
50 63
     /**
51 64
      * Receive an amount of money in cents from a customer.
52 65
      */
@@ -54,7 +67,15 @@ public class TicketMachine
54 67
     {
55 68
         balance = balance + amount;
56 69
     }
57
-
70
+    
71
+    public int getTotal(int amount){
72
+    return total;
73
+    }
74
+    
75
+    public void empty(){
76
+        total = 0;
77
+    }
78
+    
58 79
     /**
59 80
      * Print a ticket.
60 81
      * Update the total collected and

+ 16
- 9
bluej.pkg 파일 보기

@@ -1,20 +1,20 @@
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
6
-objectbench.height=101
7
-objectbench.width=461
4
+editor.fx.0.x=179
5
+editor.fx.0.y=23
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
12
+package.editor.x=480
13 13
 package.editor.y=119
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0
17
-package.numTargets=1
17
+package.numTargets=2
18 18
 package.showExtends=true
19 19
 package.showUses=true
20 20
 project.charset=UTF-8
@@ -30,3 +30,10 @@ target1.type=ClassTarget
30 30
 target1.width=120
31 31
 target1.x=80
32 32
 target1.y=50
33
+target2.height=50
34
+target2.name=Pet
35
+target2.showInterface=false
36
+target2.type=ClassTarget
37
+target2.width=80
38
+target2.x=77
39
+target2.y=138

+ 16
- 9
package.bluej 파일 보기

@@ -1,20 +1,20 @@
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
6
-objectbench.height=101
7
-objectbench.width=461
4
+editor.fx.0.x=179
5
+editor.fx.0.y=23
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
12
+package.editor.x=480
13 13
 package.editor.y=119
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0
17
-package.numTargets=1
17
+package.numTargets=2
18 18
 package.showExtends=true
19 19
 package.showUses=true
20 20
 project.charset=UTF-8
@@ -30,3 +30,10 @@ target1.type=ClassTarget
30 30
 target1.width=120
31 31
 target1.x=80
32 32
 target1.y=50
33
+target2.height=50
34
+target2.name=Pet
35
+target2.showInterface=false
36
+target2.type=ClassTarget
37
+target2.width=80
38
+target2.x=77
39
+target2.y=138