?? loansavingaccount.java
字號:
package model;import Exception.*;public class LoanSavingAccount extends SavingAccount implements Loannable { private double loanmoney = 0; public LoanSavingAccount(String password, String name, String personId, String email) { super(password, name, personId, email); } public void requestLoan(double money) { this.loanmoney += money; } // 償還貸款,首先要判斷用戶余額是否足夠,并且還要判斷貸款額是不是大于償還貸款的數(shù)額 // 用戶可以選擇是現(xiàn)金還還是用存款還. public void payLoan(double money) throws BusinessException.LoanException, BusinessException.BalanceNotEnoughException { if (this.loanmoney - money >= 0) { // if((this.getBalance()-money)<0) throw new // BusinessException.BalanceNotEnoughException("BalanceNotEnoughException--->SavingAccount // 您的余額不足 ! "); // this.setBalance(this.getBalance()+money); System.out.println("setBalance"); this.withdraw(money); this.loanmoney -= money; } else throw new BusinessException.LoanException( "LoanException-->LoanSavingAccount 您不需要還這么多貸款 ! "); } public double getLoan() { return this.loanmoney; } /* * public String toString() { return * this.getName()+"\t"+this.getPersonId()+"\t"+this.getEmail(); } */ public boolean equals(Object o) { boolean flag = super.equals(o); if (!flag) return false; Loannable c = (Loannable) o; if (this.loanmoney != c.getLoan()) return false; else return true; } public int hashCode() { // TODO Auto-generated method stub return super.hashCode()^new Double(loanmoney).hashCode(); } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -