소스 검색

Ticket Meachine

Yesoda Sanka 6 년 전
부모
커밋
40b7f14634
6개의 변경된 파일130개의 추가작업 그리고 23개의 파일을 삭제
  1. BIN
      .DS_Store
  2. 33
    0
      Heater.java
  3. 18
    5
      TicketMachine.java
  4. 23
    9
      bluej.pkg
  5. 23
    9
      package.bluej
  6. 33
    0
      student.java

BIN
.DS_Store 파일 보기


+ 33
- 0
Heater.java 파일 보기

@@ -0,0 +1,33 @@
1
+
2
+/**
3
+ * Write a description of class Heater here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Heater
9
+{
10
+    // instance variables - replace the example below with your own
11
+    private int x;
12
+
13
+    /**
14
+     * Constructor for objects of class Heater
15
+     */
16
+    public Heater()
17
+    {
18
+        // initialise instance variables
19
+        x = 0;
20
+    }
21
+
22
+    /**
23
+     * An example of a method - replace this comment with your own
24
+     *
25
+     * @param  y  a sample parameter for a method
26
+     * @return    the sum of x and y
27
+     */
28
+    public int sampleMethod(int y)
29
+    {
30
+        // put your code here
31
+        return x + y;
32
+    }
33
+}

+ 18
- 5
TicketMachine.java 파일 보기

@@ -12,21 +12,23 @@
12 12
 public class TicketMachine
13 13
 {
14 14
     // The price of a ticket from this machine.
15
-    private int price;
15
+     private int price;
16 16
     // The amount of money entered by a customer so far.
17 17
     private int balance;
18 18
     // The total amount of money collected by this machine.
19 19
     private int total;
20
+    private int status;
21
+   
20 22
 
21 23
     /**
22 24
      * Create a machine that issues tickets of the given price.
23 25
      * Note that the price must be greater than zero, and there
24 26
      * are no checks to ensure this.
25 27
      */
26
-    public TicketMachine(int ticketCost)
28
+    public TicketMachine()
27 29
     {
28
-        price = ticketCost;
29
-        balance = 0;
30
+        price = 1000;
31
+        balance = 100;
30 32
         total = 0;
31 33
     }
32 34
 
@@ -64,7 +66,7 @@ public class TicketMachine
64 66
     {
65 67
         // Simulate the printing of a ticket.
66 68
         System.out.println("##################");
67
-        System.out.println("# The BlueJ Line");
69
+        System.out.println("# The BlueJ Line"); 
68 70
         System.out.println("# Ticket");
69 71
         System.out.println("# " + price + " cents.");
70 72
         System.out.println("##################");
@@ -75,4 +77,15 @@ public class TicketMachine
75 77
         // Clear the balance.
76 78
         balance = 0;
77 79
     }
80
+
81
+public void prompt ()
82
+{
83
+     System.out.println( "Please insert the correct amount of money.");
84
+}
85
+
86
+public void showPrice ()
87
+{
88
+     System.out.println( "The price of a ticket is :" + price + " cents..");
89
+}
90
+
78 91
 }

+ 23
- 9
bluej.pkg 파일 보기

@@ -1,20 +1,20 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
2
+editor.fx.0.height=714
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
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=3
18 18
 package.showExtends=true
19 19
 package.showUses=true
20 20
 project.charset=UTF-8
@@ -24,9 +24,23 @@ readme.width=47
24 24
 readme.x=10
25 25
 readme.y=10
26 26
 target1.height=50
27
-target1.name=TicketMachine
27
+target1.name=student
28 28
 target1.showInterface=false
29 29
 target1.type=ClassTarget
30
-target1.width=120
31
-target1.x=80
32
-target1.y=50
30
+target1.width=80
31
+target1.x=10
32
+target1.y=110
33
+target2.height=50
34
+target2.name=Heater
35
+target2.showInterface=false
36
+target2.type=ClassTarget
37
+target2.width=80
38
+target2.x=100
39
+target2.y=110
40
+target3.height=50
41
+target3.name=TicketMachine
42
+target3.showInterface=false
43
+target3.type=ClassTarget
44
+target3.width=120
45
+target3.x=80
46
+target3.y=50

+ 23
- 9
package.bluej 파일 보기

@@ -1,20 +1,20 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
2
+editor.fx.0.height=714
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
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=3
18 18
 package.showExtends=true
19 19
 package.showUses=true
20 20
 project.charset=UTF-8
@@ -24,9 +24,23 @@ readme.width=47
24 24
 readme.x=10
25 25
 readme.y=10
26 26
 target1.height=50
27
-target1.name=TicketMachine
27
+target1.name=student
28 28
 target1.showInterface=false
29 29
 target1.type=ClassTarget
30
-target1.width=120
31
-target1.x=80
32
-target1.y=50
30
+target1.width=80
31
+target1.x=10
32
+target1.y=110
33
+target2.height=50
34
+target2.name=Heater
35
+target2.showInterface=false
36
+target2.type=ClassTarget
37
+target2.width=80
38
+target2.x=100
39
+target2.y=110
40
+target3.height=50
41
+target3.name=TicketMachine
42
+target3.showInterface=false
43
+target3.type=ClassTarget
44
+target3.width=120
45
+target3.x=80
46
+target3.y=50

+ 33
- 0
student.java 파일 보기

@@ -0,0 +1,33 @@
1
+
2
+/**
3
+ * Write a description of class student here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+ class student
9
+{
10
+    // instance variables - replace the example below with your own
11
+    private int x;
12
+
13
+    /**
14
+     * Constructor for objects of class student
15
+     */
16
+    public student()
17
+    {
18
+        // initialise instance variables
19
+        x = 0;
20
+    }
21
+
22
+    /**
23
+     * An example of a method - replace this comment with your own
24
+     *
25
+     * @param  y  a sample parameter for a method
26
+     * @return    the sum of x and y
27
+     */
28
+    public int sampleMethod(int y)
29
+    {
30
+        // put your code here
31
+        return x + y;
32
+    }
33
+}