Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TicketMachine
- {
- private int price;
- private int balance;
- private int total;
- public TicketMachine(int ticketCost)
- {
- price = ticketCost;
- balance = 0;
- total = 0;
- }
- /**
- * Return the price of a ticket.
- */
- public int getPrice()
- {
- return price;
- }
- public int getBalance()
- {
- return balance;
- }
- /**
- * Receive an amount of money in cents from a customer.
- */
- public void insertMoney(int amount)
- {
- balance = balance + amount;
- }
- public void printTicket()
- {
- System.out.println("##################");
- System.out.println("# The BlueJ Line");
- System.out.println("# Ticket");
- System.out.println("# " + price + " rupiah.");
- System.out.println("##################");
- System.out.println();
- total = total + balance;
- balance = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement