java.lang.ObjectTicketMachine
TicketMachine models a ticket machine that issues flat-fare tickets. The price of a ticket is specified via the constructor. Instances will check to ensure that a user only enters sensible amounts of money, and will only print a ticket if enough money has been input.
Constructor Summary | |
TicketMachine(int ticketCost)
Create a machine that issues tickets of the given price. |
Method Summary | |
int |
emptyMachine()
Empty the money in the machine The amount of money is returned |
int |
getBalance()
Return The amount of money already inserted for the next ticket. |
int |
getPrice()
|
void |
insertMoney(int amount)
Receive an amount of money in cents from a customer. |
void |
printTicket()
Print a ticket if enough money has been inserted, and reduce the current balance by the ticket price. |
int |
refundBalance()
Return the money in the balance. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TicketMachine(int ticketCost)
Method Detail |
public int emptyMachine()
public int getBalance()
public int getPrice()
public void insertMoney(int amount)
public void printTicket()
public int refundBalance()