checkingaccount.java
来自「本程序用Java语言描述了一个基本的银行管理系统」· Java 代码 · 共 32 行
JAVA
32 行
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 + =
减小字号Ctrl + -
显示快捷键?