checkingaccount.java
来自「东软JAVA内部资料」· Java 代码 · 共 41 行
JAVA
41 行
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 + =
减小字号Ctrl + -
显示快捷键?