Started implumenting a GUI for the program.

This commit is contained in:
2025-03-20 13:07:47 +01:00
parent 5f192d1860
commit d8e0c12b9f
11 changed files with 413 additions and 33 deletions

View File

@@ -1,5 +1,9 @@
package me.zacharias.bank;
import me.zacharias.bank.transaction.Transaction;
import me.zacharias.bank.transaction.TransactionType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.UUID;
@@ -14,14 +18,16 @@ public class User {
accounts = new ArrayList<>();
}
public void createAccount(String name, double balance) {
Account account = new BankAccount(name, balance);
public UUID createAccount(String name) {
Account account = new BankAccount(name);
accounts.add(account);
return account.getId();
}
public void createSavingsAccount(String name, double balance) {
Account account = new SavingsAccount(name, balance);
public UUID createSavingsAccount(String name) {
Account account = new SavingsAccount(name);
accounts.add(account);
return account.getId();
}
public Account getAccount(String name) {
@@ -33,7 +39,7 @@ public class User {
return null;
}
public Account getAccount(UUID id) {
public Account getAccount(@NotNull UUID id) {
for (Account account : accounts) {
if (account.id.equals(id)) {
return account;
@@ -42,17 +48,25 @@ public class User {
return null;
}
public void deleteAccount(Account account) {
public void deleteAccount(@NotNull Account account) {
Account base = null;
for(Account a : accounts) {
if(a instanceof BankAccount) {
if(a.getId().equals(account.getId())) {
base = a;
}
}
if(base == null) {
throw new IllegalArgumentException("No bank accounts found");
throw new IllegalArgumentException("No other bank accounts found");
}
base.TransferTransaction(account.getBalance(), "Account closed", account.getId(), base.getId());
base.handleTransaction(new Transaction(account.getBalance(), "Account closed", account.getId(), base.getId(), TransactionType.CLOSE));
accounts.remove(account);
}
public String getName() {
return name;
}
public ArrayList<Account> getAccounts() {
return accounts;
}
}