⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regularaccount.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
package Accounts;

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

/**	A regular account that allows deposits and keeps a log of transactions on the account. */
public abstract class RegularAccount extends Account
{
	/**	A collection of transactions. */
	protected LinkedListUos log;

	/**	Constructs a RegularAccount from a Customer and an account number. */ 
	public RegularAccount(Customer c, int n)
	{
		super(c, n);
		log = new LinkedListUos();
	}

	/**	Deposit 'a' dollars into the account. */
	public void deposit(float a)
	{
		balance += a;
	}
	
	/**	Add a transaction to the collection of transactions. */
	public void logTrans(int d, String des, float amt, float loc)
	{
		Transaction t = new Transaction(d, des, amt, loc);
		log.insertLast(t);
	}
	
	/**	Generate a listing of all the transactions that are currently in the transaction log. */
	public String generateMonthlyStmt()
	{
		String result = "\nTransactions for account " + number 
				+ " with owner " + owner.name() + ":" + Transaction.header();
		log.goFirst();
		while (!log.after())
		{	
			result += log.item().toString();
			log.goForth();
		}
		return result + "\nFinal balance is $" + FormatUos.withDecimals(balance, 2) + "\n";
	}
}

⌨️ 快捷键说明

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