Vexus

Exercise 3.3

Oct 1st, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class BankAccount
  2. {
  3.     public static void main (String[] args) {
  4.         BankAccount diddle = new BankAccount();
  5.         diddle.deposit(1000);
  6.         diddle.withdraw(500);
  7.         diddle.withdraw(400);
  8.         System.out.println(balance);
  9.         System.out.println("expected: 100");
  10.        
  11.     }
  12.     private static double balance;{
  13.        
  14.     }
  15.    
  16.     public void deposit(double amount) {
  17.         balance = balance + amount;
  18.  
  19.     }
  20.    
  21.     public void withdraw(double amount) {
  22.         balance = balance - amount;
  23.     }
  24.    
  25.     public static double getBalance() {
  26.         return balance;
  27.        
  28.    
  29.    
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment