Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package AG_Banks;
  2.  
  3. public class AG_Account {
  4.  
  5.     public int money;
  6.     public int bills;
  7.  
  8.     public AG_Account(int startMoney) {
  9.  
  10.         money=startMoney;
  11.  
  12.     }
  13.  
  14.     public AG_Account() {
  15.  
  16.         money = 0;
  17.     }
  18.  
  19.     public void deposit(int amount) {
  20.  
  21.         money = money + amount;
  22.  
  23.     }
  24.  
  25.     public int withdraw (int amount) {
  26.  
  27.         if(money>=amount){
  28.         this.money = money - amount;
  29.         return amount;
  30.         } else {
  31.             int charge=35;
  32.             overdraft(charge);
  33.         }
  34.  
  35.         return 0;
  36.     }
  37.  
  38.     public int getBalance(){
  39.  
  40.         return money;
  41.     }
  42.  
  43.     private int overdraft(int charge){
  44.  
  45.         money = money - charge;
  46.         return 0;
  47.     }
  48.  
  49.  
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement