-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
42 lines (32 loc) · 789 Bytes
/
Copy pathTransaction.java
File metadata and controls
42 lines (32 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class Transaction
{
private double amount;
private Date timestamp;
private String memo;
private Account inAccount;
public Transaction(double amount,Account inAccount)
{
this.amount=amount;
this.inAccount=inAccount;
this.timestamp=new Date();
this.memo="";
}
public Transaction(double amount,String memo,Account inAccount)
{
this(amount,inAccount);
this.memo=memo;
}
public double getAmount()
{
return this.amount;
}
public String getSummaryLine(){
if(this.amount>=0)
{
return String.format("%s : $%.02f : %s",this.timestamp.toString(),this.amount,this.memo);
}else{
return String.format("%s : $(%.02f) : %s",this.timestamp.toString(),-this.amount,this.memo);
}
}
}