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. This version has no output to the console window other than the printing of the ticket.
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 Total is reset to 0 |
int |
getBalance()
|
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()
Gives change to the user Balance is reset to 0 |
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()