checkingaccount.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 46 行

JAVA
46
字号
package Accounts;

import People.Customer;
import dslib.base.FormatUos;

/**	A checking account allows an overdraft up to the line of credit of the account. */
public class CheckingAccount extends RegularAccount
{
	/**	The line of credit for the account. */
	protected float lineOfCredit;

	public CheckingAccount(Customer c, int n)
	{
		super(c, n);
	}

	/**	Change the line of credit for the account. */
	public void setLoc(float amount)
	{
		lineOfCredit = amount;
	}

	/**	The line of credit for the account. */
	public float lineOfCredit()
	{
		return lineOfCredit;
	}

	/**	Account information for the monthly statement. */
	public String generateMonthlyStmt()
	{
		return super.generateMonthlyStmt() + "The line of credit is $" 
				+ FormatUos.withDecimals(lineOfCredit, 2) + "\n";
	}

	/**	String representation of the account. */
	public String toString()
	{
		return "Checking account " + number + ": Owner " + owner.name()
				+ "\n" + FormatUos.pad("", 11, 'l') + "Balance "
				+ FormatUos.withDecimals(balance, 2)
				+ "\n" + FormatUos.pad("", 11, 'l') + "Line of credit " 
				+ FormatUos.withDecimals(lineOfCredit, 2) + "\n";
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?