📄 checkingaccount.java
字号:
package com.neusoft.course.oo;
public class CheckingAccount extends Account {
private double overdraftProtection;
public CheckingAccount(double balance, double protection) {
super(balance);
this.overdraftProtection = protection;
}
@Override
public boolean withDraw(double amount) {
double result = balance - amount;
if ((result + overdraftProtection) >= 0) {
balance = result;
return true;
} else {
return false;
}
}
public double getOverdraftProtection() {
return overdraftProtection;
}
public void setOverdraftProtection(double overdraftProtection) {
this.overdraftProtection = overdraftProtection;
}
public String getInfo() {
return "checking: " + String.valueOf(balance);
}
public static void main(String[] args) {
Account account = new CheckingAccount(500, 500);
boolean result = account.withDraw(800);
System.out.println(result);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -