Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package atm;
  2.  
  3. public class Atm {
  4. private Card currentCard;
  5.  
  6. void insertCard(Card card) {
  7. //todo DZ избежать двойной повторной вставки
  8. if (currentCard == null) {
  9. currentCard = card;
  10. System.out.println("Вставили карточку");
  11. } else {
  12. System.out.println("Карточка уже в банкомате");
  13. }
  14. }
  15.  
  16. void eject() {
  17. currentCard = null;
  18. System.out.println("Спасибо! Не забудьте забрать вашу карту");
  19. }
  20.  
  21. void showBalance() {
  22. //todo DZ проверить вставлена ли карта
  23. if (currentCard != null) {
  24. System.out.println("Balance " + currentCard.getBalance());
  25. } else {
  26. System.out.println("Вставьте вашу карту");
  27. }
  28. }
  29.  
  30. void withdraw(int amount) {
  31. //todo DZ проверить вставлена ли карта
  32. if (currentCard != null) {
  33. currentCard.withdraw(amount);
  34. }else {
  35. System.out.println("Отсутствует карта");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement