Advertisement
hasancse1991

Untitled

Aug 18th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package com.delete;
  2.  
  3. public class Atm {
  4.  
  5. private double balance; // balance of ATM machine
  6. private BankApi bankApi;
  7.  
  8. public double checkBalance() {
  9. validateCardInfo();
  10. validatePin();
  11. return bankApi.getAccount().getBalance();
  12. }
  13.  
  14. public void withdraw(double amount) {
  15. validateCardInfo();
  16. validatePin();
  17. bankApi.hasSufficientBalance(amount);
  18. hasSufficientBalance(amount);
  19. cashDisburse(amount);
  20. }
  21.  
  22. private void validateCardInfo() {
  23. //
  24. }
  25.  
  26. private void validatePin() {
  27. //
  28. }
  29.  
  30. private boolean hasSufficientBalance(double amount) {
  31. return balance > amount;
  32. }
  33.  
  34. private void cashDisburse(double amount) {
  35. // count note, open vault, disburse cash
  36. }
  37. }
  38.  
  39. class Account {
  40. private double balance;
  41.  
  42. public double getBalance() {
  43. return balance;
  44. }
  45. }
  46.  
  47. interface BankApi {
  48. Account getAccount();
  49. boolean hasSufficientBalance(double amount);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement