Selaa lähdekoodia

Pssssssssssst

rayskeez21 6 vuotta sitten
vanhempi
commit
5d724531e5
5 muutettua tiedostoa jossa 137 lisäystä ja 98 poistoa
  1. BIN
      .DS_Store
  2. 117
    0
      Student.java
  3. 0
    78
      TicketMachine.java
  4. 10
    10
      bluej.pkg
  5. 10
    10
      package.bluej

BIN
.DS_Store Näytä tiedosto


+ 117
- 0
Student.java Näytä tiedosto

@@ -0,0 +1,117 @@
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
+ */
12
+public class Student{
13
+
14
+    
15
+    public class LabClass{
16
+
17
+
18
+    }
19
+
20
+    public class TicketMachine
21
+    {
22
+        // The price of a ticket from this machine.
23
+        private int price;
24
+        int status;
25
+        // The amount of money entered by a customer so far.
26
+        private int balance;
27
+        // The total amount of money collected by this machine.
28
+        private int total;
29
+
30
+        public String Pet(String petsName){    
31
+            petsName = "Cujo";  
32
+            return petsName;
33
+        }
34
+
35
+
36
+        /**
37
+         * Create a machine that issues tickets of the given price.
38
+         * Note that the price must be greater than zero, and there
39
+         * are no checks to ensure this.
40
+         */
41
+        public TicketMachine()
42
+        {
43
+            price = 1000;
44
+            balance = 0;
45
+            total = 0;
46
+            
47
+
48
+        }
49
+
50
+        public void setPrice()
51
+        {
52
+            getPrice();   
53
+        }
54
+        
55
+        public void prompt()
56
+        {
57
+          System.out.println("Please insert the correct amount of money.");  
58
+        }
59
+        
60
+        public void showPrice()
61
+        {
62
+         System.out.println("The price of a ticket " + price +" cents." );   
63
+        }
64
+        
65
+        public void empty()
66
+        {
67
+         total = 0;   
68
+        }
69
+        
70
+
71
+        /**
72
+         * Return the price of a ticket.
73
+         */
74
+        public int getPrice()
75
+        {
76
+            return price;
77
+        }
78
+
79
+        /**
80
+         * Return the amount of money already inserted for the
81
+         * next ticket.
82
+         */
83
+        public int getBalance()
84
+        {
85
+            return balance;
86
+        }
87
+
88
+        /**
89
+         * Receive an amount of money in cents from a customer.
90
+         */
91
+        public void insertMoney(int amount)
92
+        {
93
+            balance = balance + amount;
94
+        }
95
+
96
+        /**
97
+         * Print a ticket.
98
+         * Update the total collected and
99
+         * reduce the balance to zero.
100
+         */
101
+        public void printTicket()
102
+        {
103
+            // Simulate the printing of a ticket.
104
+            System.out.println("##################");
105
+            System.out.println("# The BlueJ Line");
106
+            System.out.println("# Ticket");
107
+            System.out.println("# " + "price" + " cents.");
108
+            System.out.println("##################");
109
+            System.out.println();
110
+
111
+            // Update the total collected with the balance.
112
+            total = total + balance;
113
+            // Clear the balance.
114
+            balance = 0;
115
+        }
116
+    }
117
+}

+ 0
- 78
TicketMachine.java Näytä tiedosto

@@ -1,78 +0,0 @@
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
- */
12
-public class TicketMachine
13
-{
14
-    // The price of a ticket from this machine.
15
-    private int price;
16
-    // The amount of money entered by a customer so far.
17
-    private int balance;
18
-    // The total amount of money collected by this machine.
19
-    private int total;
20
-
21
-    /**
22
-     * Create a machine that issues tickets of the given price.
23
-     * Note that the price must be greater than zero, and there
24
-     * are no checks to ensure this.
25
-     */
26
-    public TicketMachine(int ticketCost)
27
-    {
28
-        price = ticketCost;
29
-        balance = 0;
30
-        total = 0;
31
-    }
32
-
33
-    /**
34
-     * Return the price of a ticket.
35
-     */
36
-    public int getPrice()
37
-    {
38
-        return price;
39
-    }
40
-
41
-    /**
42
-     * Return the amount of money already inserted for the
43
-     * next ticket.
44
-     */
45
-    public int getBalance()
46
-    {
47
-        return balance;
48
-    }
49
-
50
-    /**
51
-     * Receive an amount of money in cents from a customer.
52
-     */
53
-    public void insertMoney(int amount)
54
-    {
55
-        balance = balance + amount;
56
-    }
57
-
58
-    /**
59
-     * Print a ticket.
60
-     * Update the total collected and
61
-     * reduce the balance to zero.
62
-     */
63
-    public void printTicket()
64
-    {
65
-        // Simulate the printing of a ticket.
66
-        System.out.println("##################");
67
-        System.out.println("# The BlueJ Line");
68
-        System.out.println("# Ticket");
69
-        System.out.println("# " + price + " cents.");
70
-        System.out.println("##################");
71
-        System.out.println();
72
-
73
-        // Update the total collected with the balance.
74
-        total = total + balance;
75
-        // Clear the balance.
76
-        balance = 0;
77
-    }
78
-}

+ 10
- 10
bluej.pkg Näytä tiedosto

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
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
2
+editor.fx.0.height=0
3
+editor.fx.0.width=0
4
+editor.fx.0.x=0
5
+editor.fx.0.y=0
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=267
13
+package.editor.y=50
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0

+ 10
- 10
package.bluej Näytä tiedosto

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=722
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
2
+editor.fx.0.height=0
3
+editor.fx.0.width=0
4
+editor.fx.0.x=0
5
+editor.fx.0.y=0
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=267
13
+package.editor.y=50
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0