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

📄 transaction.java

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

import dslib.base.FormatUos;

/**	This class saves the details of a command for monthly statements
	and to permit audits.*/
public class Transaction
{
	/**	The amount of money involved in the transaction */
	float amount;

	/** 	The line of credit involved in the transaction */
	float lineOfCredit;

	/**	The date of the transaction */
	int date;

	/**	A description of the transaction */
	String description;
	
	/**	A constructor for a transaction that takes in
		a date, description, amount, and line of credit */
	public Transaction(int d, String des, float amt, float loc)
	{
		date = d;
		description = des;
		amount = amt;
		lineOfCredit = loc;
	}
	
	/** Return a header line for the output of transactions via toString(). */
	public static String header()
	{
		return "\n" + FormatUos.pad("Date", 5, 'l') + "  "
					+ FormatUos.pad("Description of transaction", 36, 'l')
					+ FormatUos.pad("Amount", 9, 'r');
	}
	
	/**	Return a string representation of the transaction */
	public String toString()
	{
		String descWithLOC = description;
		if(lineOfCredit != 0.0)
			descWithLOC += FormatUos.withDecimals(lineOfCredit, 2);
		return  "\n" + FormatUos.pad(date, 5, 'r') + "  "
						+ FormatUos.pad(descWithLOC, 36, 'l')
						+ FormatUos.pad(FormatUos.withDecimals(amount, 2), 9, 'r');
	}
}

⌨️ 快捷键说明

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