Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package edu.ua.cs.cs200.lab10;
  2.  
  3. public class Atm {
  4.  
  5. private double balance;
  6.  
  7. public double get_balance() {
  8. return balance;
  9. }
  10.  
  11. /*
  12. * This class is licensed with GPL.
  13. */
  14.  
  15. public void initialBalance(double startingBalance) {
  16. this.balance = startingBalance;
  17. }
  18.  
  19. /** Class allows user to deposit money into account.
  20. * @param amount is amount of money to add to account
  21. * @return true if amount is not equal to 0.
  22. */
  23. public boolean deposit(double amount) {
  24. if (amount < 0) {
  25. return false;
  26. }
  27. this.balance += amount;
  28. return true;
  29. }
  30.  
  31. /** Class allows user to withdraw money if funds are available.
  32. * @param amount is amount to withdraw
  33. * @return true if funds are available, otherwise false
  34. */
  35. public boolean withdraw(double amount) {
  36. if (amount < 0) {
  37. return false;
  38. }
  39. if (this.balance < amount) {
  40. return false;
  41. }
  42. this.balance -= amount;
  43. return true;
  44. }
  45.  
  46. public void doNothing() {
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement