Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. /*Barbra Basiga 2010*/
  2.  
  3. package AG_Banks;
  4. public class AG_Account
  5. {
  6.     private int money;
  7.     public AG_Account(int amountOfMoney)
  8.     {
  9.         money = amountOfMoney;
  10.     }
  11.     public AG_Account()
  12.     {
  13.         money = 0;
  14.     }                            
  15.     public void deposit(int amount)
  16.     {
  17.         money = money + amount;
  18.     }
  19.     public int withdraw(int amount)
  20.     {
  21.         boolean od=false;
  22.         if (money>=amount)
  23.         {      
  24.             money = money - amount;
  25.             return amount;
  26.         }
  27.         if ((money<amount && money>=0)&& (!od))
  28.         {
  29.             overdraft(35);
  30.             od=true;
  31.         }
  32.     return 0;
  33.     }
  34.     public int getbalance()
  35.     {
  36.         return money;
  37.     }
  38.     private void overdraft(int amount)
  39.     {
  40.         money = money - amount;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement