Advertisement
therrontelford

AccountBalance

Oct 1st, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. /*
  2. Therron Telford
  3. AP CS A
  4. October 14, 2017
  5. */
  6.  
  7. public class AccountBalance {
  8.    
  9.     private double balance;
  10.     private double deposit;
  11.     private double withdrawal;
  12.    
  13.     public AccountBalance(){
  14.        
  15.     }
  16.    
  17.     public AccountBalance(double bal, double dep, double with){
  18.         balance = bal;
  19.         deposit= dep;
  20.         withdrawal= with;
  21.         balance = balance + deposit - withdrawal;
  22.     }
  23.    
  24.     public void setBalance(double beginning){
  25.         balance = beginning;
  26.     }
  27.    
  28.     public double myBalance(){
  29.        
  30.         return balance;
  31.        
  32.     }
  33.    
  34.     public void myWithdrawal(double withdraw){
  35.        
  36.         withdrawal = withdraw;
  37.         balance = balance - withdrawal;
  38.     }
  39.    
  40.     public void myDeposit(double dep){
  41.         deposit = dep;
  42.         balance = balance + deposit;
  43.     }
  44.    
  45.     public String toString(){
  46.         return "My balance is " + balance;
  47.     }
  48. }
  49.  
  50. /* in the main of AccountBalanceTest
  51.  * AccountBalance mine = new AccountBalance();
  52.  * mine.balance(100);
  53.  * mine.deposit(800);
  54.  * mine withdrawal(150);
  55.  * System.out.println(mine);
  56. */
  57.  
  58. //How many constructors?  Accessor?  Mutator?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement