|
|
|
|
4
|
|
4
|
|
5
|
look for the Chapter reading you need in the doc folder.
|
5
|
look for the Chapter reading you need in the doc folder.
|
6
|
|
6
|
|
|
|
7
|
+Work through all these exercises.
|
|
|
8
|
+
|
7
|
* Exercise 2.1 Create a TicketMachine object on the object bench and take a look
|
9
|
* Exercise 2.1 Create a TicketMachine object on the object bench and take a look
|
8
|
at its methods. You should see the following: getBalance, getPrice, insertMoney,
|
10
|
at its methods. You should see the following: getBalance, getPrice, insertMoney,
|
9
|
and printTicket. Try out the getPrice method. You should see a return value containing
|
11
|
and printTicket. Try out the getPrice method. You should see a return value containing
|
|
|
|
|
63
|
private Game game;
|
65
|
private Game game;
|
64
|
```
|
66
|
```
|
65
|
* Exercise 2.13 In the following field declaration from the TicketMachine class
|
67
|
* Exercise 2.13 In the following field declaration from the TicketMachine class
|
66
|
-`private int price;`
|
|
|
|
|
68
|
+```
|
|
|
69
|
+private int price;
|
|
|
70
|
+```
|
67
|
does it matter which order the three words appear in? Edit the TicketMachine class to
|
71
|
does it matter which order the three words appear in? Edit the TicketMachine class to
|
68
|
try different orderings. After each change, close the editor. Does the appearance of the
|
72
|
try different orderings. After each change, close the editor. Does the appearance of the
|
69
|
class diagram after each change give you a clue as to whether or not other orderings are
|
73
|
class diagram after each change give you a clue as to whether or not other orderings are
|
|
|
|
|
78
|
```
|
82
|
```
|
79
|
public Student(String name)
|
83
|
public Student(String name)
|
80
|
```
|
84
|
```
|
81
|
-* Exercise 2.17 How many parameters does the following constructor have andwhat are their types?
|
|
|
|
|
85
|
+* Exercise 2.17 How many parameters does the following constructor have and what are their types?
|
82
|
```
|
86
|
```
|
83
|
public Book(String title, double price)
|
87
|
public Book(String title, double price)
|
84
|
```
|
88
|
```
|
85
|
-* Exercise 2.18 Can you guess what types some of the Bookclass’s fields mightbe? Can you assume anything about the names of its fields?
|
|
|
|
|
89
|
+* Exercise 2.18 Can you guess what types some of the Book class’s fields might be? Can you assume anything about the names of its fields?
|
|
|
90
|
+
|
|
|
91
|
+Work all Exercises from 2.19 to 2.58 that are NOT marked *Challenge exercise*.
|
|
|
92
|
+READ upto and INCLUDING section 2.15 of this chapter.
|