?? transaction.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 + -