📄 savingaccount.java
字号:
package model;
import exception.*;
/**
* 储蓄账户类(SavingAccount) 作者:DrMeng 日期:08/07/26
*/
public class SavingAccount extends Account {
public SavingAccount() {
super();
// TODO Auto-generated constructor stub
}
public SavingAccount(String password, String name, String personId,
String email, double balance) {
super(password, name, personId, email, balance);
// TODO Auto-generated constructor stub
}
@Override
// 取款方法根据不同的子类而不同,因此,改为抽象方法,在两个子类中分别实现
public void withdraw(double money) throws BalanceNotEnoughException {
if (this.getBalance() >= money) {
this.setBalance(this.getBalance() - money);
System.out.println("==========<<取款>>成功!!============");
System.out.println("<<取款>>成功!!======>>" + "账户ID:" + this.getId()
+ "\t姓名:" + this.getName() + "\t上次余额:"
+ (this.getBalance() + money) + "\t取款:" + money
+ "\t当前总金额:" + this.getBalance());
} else {
throw new BalanceNotEnoughException("储蓄类账户:" + this.getName()
+ "\t--->你的余额不足!");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -