forked from madonawambua/Bank-Account-Draft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
executable file
·48 lines (35 loc) · 953 Bytes
/
Transaction.java
File metadata and controls
executable file
·48 lines (35 loc) · 953 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
43
44
45
46
47
48
package Root;
import java.util.Date;
/**
* @author syombua
*
*/
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){
//call the two arg constructor first
this(amount, inAccount);
//set the memo
this.memo = memo;
}
public double getAmount() {
// TODO Auto-generated method stub
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);
}
}
}