Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TollMachine
- {
- private int cost;
- private Account_Database acc_db;
- private Keypad keypad;
- private Nota nota;
- private Screen screen;
- private Gate gate;
- public TollMachine()
- {
- cost = 10000;
- acc_db = new Account_Database();
- keypad = new Keypad();
- screen = new Screen();
- gate = new Gate();
- }
- public void run()
- {
- while(true)
- {
- gate.closeGate();
- screen.displayMessageLine("Please enter your Card Number\n");
- int accNum = keypad.getInput();
- if(acc_db.authenticateUser(accNum))
- {
- if(acc_db.getAccountBalance(acc_db.getAccount(accNum)) >= cost)
- {
- acc_db.tollpay(acc_db.getAccount(accNum), cost);
- nota = new Nota(acc_db.getAccount(accNum).getBalance(), cost);
- nota.print();
- screen.displayMessageLine("Thank you for using our service\nPlease take your card and proof of transaction\n");
- gate.openGate();
- }
- else
- {
- screen.displayMessageLine("Insufficient funds\nPlease take your card back\n");
- }
- }
- else
- {
- screen.displayMessageLine("Card Number not found\nPlease take your card back");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement