|
@@ -8,8 +8,8 @@ There is 35 pages of reading and exercises in the chapter.
|
8
|
8
|
Work through all these exercises. You edit this file with your answers for these exercises.
|
9
|
9
|
|
10
|
10
|
### Exercise 2.1
|
11
|
|
-* Create a `TicketMachine` object on the object bench.
|
12
|
|
-* The following methods should be available upon invoking it from the object bench `getBalance`, `getPrice`, `insertMoney`, `printTicket`.
|
|
11
|
+* Create a TicketMachine object on the object bench.
|
|
12
|
+* Upon viewing its methods, `getBalance`, `getPrice`, `insertMoney`, `printTicket`.
|
13
|
13
|
* Use `getPrice` method to view the value of the price of the tickets that was set when this object was created.
|
14
|
14
|
* Use `insertMoney` method to simulate inserting an amount of money into the machine.
|
15
|
15
|
* Use `getBalance` to check that the machine has a record of the amount inserted.
|
|
@@ -60,7 +60,8 @@ in the outer wrapper of a class?
|
60
|
60
|
|
61
|
61
|
### Exercise 2.11
|
62
|
62
|
* What do you think is the type of each of the following fields?
|
63
|
|
-```
|
|
63
|
+
|
|
64
|
+```java
|
64
|
65
|
private int count;
|
65
|
66
|
private Student representative;
|
66
|
67
|
private Server host;
|
|
@@ -68,7 +69,8 @@ private Server host;
|
68
|
69
|
|
69
|
70
|
### Exercise 2.12
|
70
|
71
|
* What are the names of the following fields?
|
71
|
|
-```
|
|
72
|
+
|
|
73
|
+```java
|
72
|
74
|
private boolean alive;
|
73
|
75
|
private Person tutor;
|
74
|
76
|
private Game game;
|
|
@@ -76,11 +78,11 @@ private Game game;
|
76
|
78
|
### Exercise 2.13
|
77
|
79
|
|
78
|
80
|
In the following field declaration from the TicketMachine class<br>
|
79
|
|
-```
|
|
81
|
+
|
|
82
|
+```java
|
80
|
83
|
private int price;
|
81
|
|
-```<br>
|
|
84
|
+```
|
82
|
85
|
does it matter which order the three words appear in?
|
83
|
|
-
|
84
|
86
|
* Edit the `TicketMachine` class to try different orderings. After each change, close the editor.
|
85
|
87
|
* Does the appearance of the class diagram after each change give you a clue as to whether or not other orderings are
|
86
|
88
|
possible?
|