37 lines
704 B
Java
37 lines
704 B
Java
package Week8_Lab;
|
|
|
|
public class CheckingAccount extends InsufficientFundsException{
|
|
|
|
private double balance;
|
|
private int number;
|
|
|
|
public CheckingAccount(double amount) {
|
|
super(amount);
|
|
}
|
|
|
|
public CheckingAccount(){
|
|
this(0);
|
|
}
|
|
|
|
public void deposit(double amount){
|
|
if (amount > 0){
|
|
this.balance += amount;
|
|
}
|
|
}
|
|
|
|
public void withdraw(double amount) throws InsufficientFundsException{
|
|
if (amount > this.balance){
|
|
throw new InsufficientFundsException(amount);
|
|
}
|
|
}
|
|
public double getBalance(){
|
|
return this.balance;
|
|
}
|
|
|
|
public int getNumber(){
|
|
return this.number;
|
|
}
|
|
|
|
|
|
}
|