📄 checkingaccount.java
字号:
package banking.domain;
public class CheckingAccount extends Account {
private double overdraftProtection;
public CheckingAccount(double balance){
super(balance);
this.overdraftProtection = 0.0;
}
public CheckingAccount(double balance, double oP){
super(balance);
this.overdraftProtection = oP;
}
public void withdraw(double amt) throws OverdraftException{
if (this.balance-amt>0.0){
this.balance -= amt;
}
else if (this.overdraftProtection==0.0)
throw new OverdraftException("No overdraft protection", amt-this.balance);
else if (this.balance+this.overdraftProtection-amt>0.0){
this.overdraftProtection -= (amt-this.balance);
this.balance = 0.0;
}
else
throw new OverdraftException("Insufficient funds for overdraft protection", amt-this.balance);
}
public double getOverdraftProtection(){
return this.overdraftProtection;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -