📄 loansavingaccount.java
字号:
package tarena.bank.server;
import java.io.Serializable;
public class LoanSavingAccount extends SavingAccount implements
AccountInterface ,Serializable{
public static final int ACCOUNT_TYPE=2;
private double loan;
public LoanSavingAccount(long id, String passwd, String name,
String personId, String email,double balance,int type) {
super(id, passwd, name, personId, email,balance,type);
// this.loan=this.getLoan();
}
public double getAllLoan() {
return this.getLoan();
}
public void payLoan(double money) {
if (this.getBalance() > 0) {
if (money > this.getBalance()) {
money = this.getBalance();
if (this.getLoan() > 0 && money < this.getLoan()) {
this.setLoan(this.getLoan() - money);
this.setBalance(this.getBalance() - money);
System.out.println("payLoan-operation success!");
}
}
else{
if (this.getLoan() > 0 && money <= this.getLoan()) {
this.setLoan(this.getLoan() - money);
this.setBalance(this.getBalance() - money);
System.out.println("payLoan-operation success!");
}
}
}
else{
System.out.println("payLoan-operation failed!");
}
}
public void requestLoan(double money) {
if (money > 0) {
this.setLoan(money+this.getLoan());
} else {
System.out.println("LoanMoney Less than Zero,Operation canceled!");
}
}
public double getLoan() {
return loan;
}
public void setLoan(double loan) {
this.loan =loan;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -