📄 checkingaccount.java
字号:
package bank.v12;
/**
* 支票帐户
*
* @author oyotong
*
*/
public class CheckingAccount extends Account {
private double overdraft;// 透支额度
/**
* 提供支票帐户开户
*
* @param balance
* 初始额度
* @param overdraft
* 透支额度
* @throws OpenAccountException
*/
public CheckingAccount(double balance, double overdraft) throws OpenAccountException {
super(balance);
if(overdraft < 0){
throw new OpenAccountException("透支额度不能为负数!");
}
this.overdraft = overdraft;
}
/**
* 覆盖父类方法,提供透支保护
*
* @see bank.Account#deposit(double)
*/
public double withdraw(double out) throws OverDraftException {
if (out > overdraft + balance) {
// throw new OverDraftException("警告:你的余额不够!");
System.out.println("警告:你的余额不够!");
return balance;
}
// 调用父类方法
balance -= out;
System.out.println("提示:取钱操作成功.");
return balance;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -