1  public class Checking extends Account{
 2
 3    Checking(String name, double amount){
 4      this.name = name;
 5      if (amount > 0){
 6        this.balance = amount;
 7      } else {
 8        System.out.println(" wARNING: You cannot initialize an acount with a negative balance");
 9        System.out.println(" wARNING: Balance will be set to 0 instead");
10        this.balance = 0;
11      }
12    }
13
14
15    public boolean withdraw(double amount){
16      if (amount > 0 && amount <= balance) {
17        balance = balance - amount;
18        return true;
19      } else if ( amount > balance){
20        System.out.println(" wARNING: You cannot withdraw more than the current balance");
21        System.out.println(" wARNING: Your current balance is "+ this.getBalance());
22        return false;
23      } else {
24        System.out.println(" wARNING: Incorrect value given as withdrawn amount");
25        System.out.println(" wARNING: Amount requeste for withdraw "+ amount);
26        System.out.println(" wARNING: Withdraw canceled");
27        return false;
28      }
29    }
30
31    public void display(){
32      System.out.println(" ****** Checking Account Details ****** ");
33      System.out.println(" Name: "+ this.getName());
34      System.out.println(" Checking Balance: "+ this.getBalance());
35      System.out.println("\t\t\t\t ****** Checking Account Details ****** ");
36    }
37  }

Generated with vim2html
Copyright © 2003-2004 by Chip Cuccio <http://norlug.org/~chipster/finger>