Advertisement
nawamkihafahd

Untitled

Oct 26th, 2017
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public class TollMachine
  2. {
  3. private int cost;
  4. private Account_Database acc_db;
  5. private Keypad keypad;
  6. private Nota nota;
  7. private Screen screen;
  8. private Gate gate;
  9. public TollMachine()
  10. {
  11. cost = 10000;
  12. acc_db = new Account_Database();
  13. keypad = new Keypad();
  14. screen = new Screen();
  15. gate = new Gate();
  16. }
  17. public void run()
  18. {
  19. while(true)
  20. {
  21. gate.closeGate();
  22. screen.displayMessageLine("Please enter your Card Number\n");
  23. int accNum = keypad.getInput();
  24. if(acc_db.authenticateUser(accNum))
  25. {
  26. if(acc_db.getAccountBalance(acc_db.getAccount(accNum)) >= cost)
  27. {
  28. acc_db.tollpay(acc_db.getAccount(accNum), cost);
  29. nota = new Nota(acc_db.getAccount(accNum).getBalance(), cost);
  30. nota.print();
  31. screen.displayMessageLine("Thank you for using our service\nPlease take your card and proof of transaction\n");
  32. gate.openGate();
  33. }
  34. else
  35. {
  36. screen.displayMessageLine("Insufficient funds\nPlease take your card back\n");
  37. }
  38. }
  39. else
  40. {
  41. screen.displayMessageLine("Card Number not found\nPlease take your card back");
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement