git-leon a81447fe0a Update 'README.md' | 5 anni fa | |
---|---|---|
doc | 6 anni fa | |
.DS_Store | 6 anni fa | |
.gitignore | 6 anni fa | |
README.TXT | 6 anni fa | |
README.md | 5 anni fa | |
TicketMachine.java | 6 anni fa | |
bluej.pkg | 6 anni fa | |
bluej.pkh | 6 anni fa | |
package.bluej | 6 anni fa |
The second Objects lab, from the BlueJ book's second chapter.
Look for the Chapter 2 file you need in the doc folder. There is 35 pages of reading and exercises in the chapter.
Work through all these exercises. You edit this file with your answers for these exercises.
TicketMachine
object on the object bench.getBalance
, getPrice
, insertMoney
, printTicket
.getPrice
method to view the value of the price of the tickets that was set when this object was created.insertMoney
method to simulate inserting an amount of money into the machine.getBalance
to check that the machine has a record of the amount inserted.
printTicket
method. A facsimile ticket should be printed in the BlueJ terminal window.TicketMachine
class is implemented in the next section.Student
and LabClass
classes might look like – do not worry about the inner part.Does it matter whether we write
public class TicketMachine
or
class public TicketMachine
in the outer wrapper of a class?
TicketMachine
class to make the change and then close the editor window.
public
from the outer wrapper of the TicketMachine
class.printTicket
, for instance.
TicketMachine
class.
private int count;
private Student representative;
private Server host;
What are the names of the following fields?
private boolean alive;
private Person tutor;
private Game game;
In the following field declaration from the TicketMachine class
private int price;
does it matter which order the three words appear in?
Edit the TicketMachine
class to try different orderings. After each change, close the editor.
* Does the appearance of the class diagram after each change give you a clue as to whether or not other orderings are
possible?
* Check by pressing the compile button to see if there is an error message.
* Make sure that you reinstantiate the original version after your experiments!
int
whose name is status
.
public Student(String name)
public Book(String title, double price)
Book
class’s fields might be?Work all Exercises from 2.19 to 2.58 that are NOT marked Challenge exercise. READ upto and INCLUDING section 2.15 of this chapter.