|
|
|
@ -1,33 +1,39 @@
|
|
|
|
|
package bank.assessment;
|
|
|
|
|
|
|
|
|
|
import bank.assessment.states.BankAccountStates;
|
|
|
|
|
import bank.assessment.states.LoggedOutState;
|
|
|
|
|
import bank.assessment.states.NotCreatedState;
|
|
|
|
|
|
|
|
|
|
public abstract class BankAccount {
|
|
|
|
|
public class BankAccount {
|
|
|
|
|
|
|
|
|
|
private String username, password, accountNumber, sortCode;
|
|
|
|
|
private String username, password;
|
|
|
|
|
private String accountNumber;
|
|
|
|
|
private String sortCode;
|
|
|
|
|
private double balance;
|
|
|
|
|
private double overdraftLimit;
|
|
|
|
|
private boolean isPremium;
|
|
|
|
|
|
|
|
|
|
BankAccountStates bankAccountState;
|
|
|
|
|
|
|
|
|
|
BankAccount() { this.bankAccountState = NotCreatedState.getInstance(this); }
|
|
|
|
|
public BankAccount() { this.bankAccountState = NotCreatedState.getInstance(this); }
|
|
|
|
|
|
|
|
|
|
BankAccount(String username, String password, String accountNumber, String sortCode) {
|
|
|
|
|
public BankAccount(String username, String password, String sortCode, String accountNumber, boolean isPremium) {
|
|
|
|
|
this.username = username;
|
|
|
|
|
this.password = password;
|
|
|
|
|
this.accountNumber = accountNumber;
|
|
|
|
|
this.sortCode = sortCode;
|
|
|
|
|
this.bankAccountState = NotCreatedState.getInstance(this);
|
|
|
|
|
this.accountNumber = accountNumber;
|
|
|
|
|
this.isPremium = isPremium;
|
|
|
|
|
this.bankAccountState = LoggedOutState.getInstance(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BankAccount(String username, String password, String accountNumber, String sortCode, double overdraftLimit) {
|
|
|
|
|
public BankAccount(String username, String password, String sortCode, String accountNumber, boolean isPremium, double overdraftLimit) {
|
|
|
|
|
this.username = username;
|
|
|
|
|
this.password = password;
|
|
|
|
|
this.accountNumber = accountNumber;
|
|
|
|
|
this.sortCode = sortCode;
|
|
|
|
|
this.accountNumber = accountNumber;
|
|
|
|
|
this.isPremium = isPremium;
|
|
|
|
|
this.overdraftLimit = overdraftLimit;
|
|
|
|
|
this.bankAccountState = NotCreatedState.getInstance(this);
|
|
|
|
|
this.bankAccountState = LoggedOutState.getInstance(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Method Actions To Change State
|
|
|
|
@ -37,19 +43,15 @@ public abstract class BankAccount {
|
|
|
|
|
|
|
|
|
|
public void logIn() { this.bankAccountState.logIn(); }
|
|
|
|
|
|
|
|
|
|
public void logOut() {
|
|
|
|
|
this.bankAccountState.logOut();
|
|
|
|
|
}
|
|
|
|
|
public void logOut() { this.bankAccountState.logOut(); }
|
|
|
|
|
|
|
|
|
|
public void deposit() { this.bankAccountState.deposit(); }
|
|
|
|
|
|
|
|
|
|
public boolean withdraw() { return this.bankAccountState.withdraw(); }
|
|
|
|
|
public void withdraw() { this.bankAccountState.withdraw(); }
|
|
|
|
|
|
|
|
|
|
public void viewDetails() {
|
|
|
|
|
this.bankAccountState.viewDetails();
|
|
|
|
|
}
|
|
|
|
|
public void viewDetails() { this.bankAccountState.viewDetails(); }
|
|
|
|
|
|
|
|
|
|
public void deleteAccount() { this.bankAccountState.deleteAccount(); }
|
|
|
|
|
public void deleteAccount(Person person) { this.bankAccountState.deleteAccount(person); }
|
|
|
|
|
|
|
|
|
|
// Getters & Setters
|
|
|
|
|
public String getUsername() {
|
|
|
|
@ -72,22 +74,16 @@ public abstract class BankAccount {
|
|
|
|
|
return accountNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAccountNumber(String accountNumber) {
|
|
|
|
|
this.accountNumber = accountNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getSortCode() {
|
|
|
|
|
return sortCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSortCode(String sortCode) {
|
|
|
|
|
this.sortCode = sortCode;
|
|
|
|
|
}
|
|
|
|
|
public String getSortCode() { return sortCode; }
|
|
|
|
|
|
|
|
|
|
public double getBalance() {
|
|
|
|
|
return balance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isPremium() { return isPremium; }
|
|
|
|
|
|
|
|
|
|
public void setPremium(boolean premium) { isPremium = premium; }
|
|
|
|
|
|
|
|
|
|
public void setBalance(double balance) {
|
|
|
|
|
this.balance = balance;
|
|
|
|
|
}
|
|
|
|
@ -100,8 +96,8 @@ public abstract class BankAccount {
|
|
|
|
|
this.overdraftLimit = overdraftLimit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void displayBalance() {
|
|
|
|
|
System.out.println("Current Account Balance: " + balance);
|
|
|
|
|
public void displayBalance() {
|
|
|
|
|
System.out.println("Current Account Balance: " + String.format("£%.2f", balance));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|