-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
31 lines (27 loc) · 1.08 KB
/
Transaction.java
File metadata and controls
31 lines (27 loc) · 1.08 KB
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
public class Transaction {
private String transactionType;
private MonetaryValue amount;
private MonetaryValue balance;
private boolean wasSuccessful;
public Transaction(String transactionType, MonetaryValue amount, MonetaryValue balance, boolean wasSuccessful) {
this.transactionType = transactionType;
this.amount = amount;
this.balance = balance;
this.wasSuccessful = wasSuccessful;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Transaction) {
Transaction newrefObj = (Transaction) obj;
return this.transactionType.equals(newrefObj.transactionType) && this.amount.equals(newrefObj.amount)
&& this.balance.equals(newrefObj.balance) && this.wasSuccessful == newrefObj.wasSuccessful;
} else {
return false;
}
}
@Override
public String toString() {
return "Transaction Type: " + transactionType + "\nAmount " + amount + "\nNew Balance: " + balance
+ "\nWas Successful? " + wasSuccessful + "\n";
}
}