illpastethat

BankAccount

Feb 6th, 2012
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1.  
  2.    import java.lang.*;
  3.  
  4.    public abstract class BankAccount {
  5.       private double balance, balance2, balance3, deposit, withdraw;
  6.      
  7.       public BankAccount() {
  8.          balance = 0;
  9.       }
  10.       public BankAccount(double y) {
  11.          balance = y;
  12.       }
  13.       public void setBalance(double x) {
  14.          balance = x;
  15.       }
  16.       public double getBalance() {
  17.          return balance;
  18.       }
  19.       public void deposit(double x) {
  20.          balance = balance + x;
  21.       }
  22.       public void withdraw(double y) {
  23.          if ((balance - y) < 0) {
  24.             throw new RuntimeException("You will overdraw your account");
  25.          }
  26.          else {
  27.             balance = balance - y;
  28.          }
  29.       }
  30.       public String toString() {
  31.          String output;
  32.          output = "The account has a balance of: $" + this.getBalance();
  33.          return output;
  34.       }
  35.       public abstract double monthlyBalance();
  36.       public abstract String toString();
  37.    }
Add Comment
Please, Sign In to add comment