loancreditaccount.java

来自「实现银行系统的一系列功能,比如存款取款透支查询余额等」· Java 代码 · 共 51 行

JAVA
51
字号
package tarena.bank.server;

import java.io.Serializable;

public class LoanCreditAccount extends CreditAccount implements AccountInterface,Serializable{
	public static final int ACCOUNT_TYPE=3;
	private double loan;
	public LoanCreditAccount(long id,String passwd,String name,String personId,String email,double balance,int type){
		super(id,passwd,name,personId,email,balance,type);
	}
	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 + =
减小字号Ctrl + -
显示快捷键?