Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Program Mesin Tiket
- *
- * Anfasa Aliffian
- * Versi 1.0
- */
- public class TicketMachine
- {
- private int price;
- private int balance;
- private int total;
- public TicketMachine(int ticketcost)
- {
- price = ticketcost;
- balance = 0;
- total = 0;
- }
- public void getprice()
- {
- System.out.println(price);
- }
- public void getbalance()
- {
- System.out.println(balance);
- }
- public void insertmoney(int amount)
- {
- balance = balance + amount;
- getbalance();
- }
- public void printticket()
- {
- while(balance >= price)
- {
- balance = balance - price;
- System.out.println("##################");
- System.out.println("# The BlueJ Line #");
- System.out.println("# ----TICKET---- #");
- System.out.println("# Rp " + price + "\t #");
- System.out.println("##################");
- System.out.println();
- total = total + balance;
- }
- getbalance();
- }
- public void exitmachine()
- {
- total = total + balance;
- balance = 0;
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement