Made so each Transaction handler in the Account class to return the transaction object. Updated the Utils class to handle the transactions que reading and writing. Added org.json to aid in trnsaction que handling. made so accounts can update there balance and transactions from the transaction que. Added a tranfer window to handle the transfer of money between acounts.
53 lines
1.3 KiB
Java
53 lines
1.3 KiB
Java
package me.zacharias.bank.transaction;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.UUID;
|
|
|
|
public class Transaction {
|
|
private double amount;
|
|
private String description;
|
|
private UUID originator;
|
|
private UUID destination;
|
|
private TransactionType type;
|
|
private String date;
|
|
|
|
public Transaction(double amount, String description, UUID destination, UUID originator, TransactionType type) {
|
|
this.amount = amount;
|
|
this.description = description;
|
|
this.originator = originator;
|
|
this.destination = destination;
|
|
this.type = type;
|
|
date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"));
|
|
}
|
|
|
|
public double getAmount() {
|
|
return amount;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
public UUID getOriginator() {
|
|
return originator;
|
|
}
|
|
|
|
public UUID getDestination() {
|
|
return destination;
|
|
}
|
|
|
|
public TransactionType getType() {
|
|
return type;
|
|
}
|
|
|
|
public String getDate() {
|
|
return date;
|
|
}
|
|
|
|
public Transaction copy(TransactionType transactionType) {
|
|
return new Transaction(amount, description, destination, originator, transactionType);
|
|
}
|
|
}
|