Fixed some issues, and made things readible from File.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user