📄 creditcardimpl.java
字号:
// 具体值类型CreditCard的实现
package Bank;
public class CreditCardImpl extends CreditCard {
// 构造方法一
public CreditCardImpl(float init) {
this(init, 0);
}
// 构造方法二
public CreditCardImpl(float init, float limit) {
balance = init;
overdraft = limit;
}
// 往账户中存款
public void deposit(float amount) {
balance += amount;
}
// 从账户中取款
public void withdraw(float amount) throws AccountOverdraft {
if (balance + overdraft < amount) throw new AccountOverdraft();
else balance -= amount;
}
// 查询账户余额
public float getBalance() {
return balance;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -