Fixed some issues, and made things readible from File.

This commit is contained in:
2025-03-19 21:57:36 +01:00
parent 32c93fd99f
commit 5f192d1860
8 changed files with 277 additions and 25 deletions

View File

@@ -6,25 +6,41 @@ import java.util.UUID;
public class User {
UUID id;
String name;
String password;
ArrayList<Account> accounts;
public User(String name, String password) {
public User(String name) {
this.name = name;
this.password = password;
id = UUID.randomUUID();
accounts = new ArrayList<>();
}
public void createAccount(String name, int balance) {
public void createAccount(String name, double balance) {
Account account = new BankAccount(name, balance);
accounts.add(account);
}
public void createSavingsAccount(String name, int balance) {
public void createSavingsAccount(String name, double balance) {
Account account = new SavingsAccount(name, balance);
accounts.add(account);
}
public Account getAccount(String name) {
for (Account account : accounts) {
if (account.name.equals(name)) {
return account;
}
}
return null;
}
public Account getAccount(UUID id) {
for (Account account : accounts) {
if (account.id.equals(id)) {
return account;
}
}
return null;
}
public void deleteAccount(Account account) {
Account base = null;