📄 creditaccount.java
字号:
package model;
/**
* 信用账户类(CreditAccount)
* 作者:DrMeng 日期:08/07/26
*/
import exception.*;
// 信用账户类(CreditAccount)
public class CreditAccount extends Account {
private double ceiling;// ceiling 透支额度
public CreditAccount() {
super();
// TODO Auto-generated constructor stub
}
public CreditAccount(String password, String name, String personId,
String email, double balance) {
super(password, name, personId, email, balance);
// TODO Auto-generated constructor stub
}
/**
*
* @return'
*/
public double getCeiling() {
return ceiling;
}
public void setCeiling(double ceiling) {
this.ceiling = ceiling;
}
@Override
// 取款方法根据不同的子类而不同,因此,改为抽象方法,在两个子类中分别实现
public void withdraw(double money) throws BalanceNotEnoughException {
// 判断有没有超出透支额度范围
if (money - this.getBalance() <= ceiling) {
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("透支额度不足");
}
}
@Override
public boolean equals(Object o) {
boolean flag = super.equals(o);
if (!flag)
return flag;
CreditAccount ca = (CreditAccount) o;
if (this.ceiling == ca.ceiling)
return true;
else
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -