java.lang.ObjectTicketMachine
public class TicketMachine
TicketMachine models a naive ticket machine that issues flat-fare tickets. The price of a ticket is specified via the constructor. It is a naive machine in the sense that it trusts its users to insert enough money before trying to print a ticket. It also assumes that users enter sensible amounts.
Constructor Summary | |
---|---|
TicketMachine(int ticketCost)
Create a machine that issues tickets of the given price. |
Method Summary | |
---|---|
int |
getBalance()
Return the amount of money already inserted for the next ticket. |
int |
getPrice()
Return the price of a ticket. |
void |
insertMoney(int amount)
Receive an amount of money in cents from a customer. |
void |
printTicket()
Print a ticket. |
Methods inherited from class |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TicketMachine(int ticketCost)
Method Detail |
---|
public int getBalance()
public int getPrice()
public void insertMoney(int amount)
public void printTicket()