Complete Method Actions For Different States

master
Hammy 4 years ago
parent fbe7e2294d
commit 695dafcbe9

@ -19,7 +19,7 @@ public class LoggedInState implements BankAccountStates {
@Override @Override
public void createAccount(Person person) { public void createAccount(Person person) {
System.out.println("This Account Is Already Registered With Us. Please Log In!"); System.out.println("This Account Is Already Registered With Us. You Are Already Logged In!");
} }
@Override @Override
@ -29,7 +29,8 @@ public class LoggedInState implements BankAccountStates {
@Override @Override
public void logOut() { public void logOut() {
// Log out! System.out.println("You Are Now Logged Out!");
bankAccount.changeBankAccountState(LoggedOutState.getInstance(bankAccount));
} }
@Override @Override

@ -1,7 +1,6 @@
package bank.assessment.states; package bank.assessment.states;
import bank.assessment.BankAccount; import bank.assessment.BankAccount;
import bank.assessment.BasicAccount;
import bank.assessment.Console; import bank.assessment.Console;
import bank.assessment.Person; import bank.assessment.Person;
@ -41,12 +40,12 @@ public class LoggedOutState implements BankAccountStates {
@Override @Override
public void logOut() { public void logOut() {
System.out.println("You Have Already Logged Out! Please Log in!"); System.out.println("You Have Already Logged Out!");
} }
@Override @Override
public void deposit() { public void deposit() {
System.out.println("Sorry, Please Log In First Before Trying Deposit Cash!");
} }
@Override @Override
@ -57,16 +56,12 @@ public class LoggedOutState implements BankAccountStates {
@Override @Override
public void viewDetails() { public void viewDetails() {
System.out.println("There Are No Account Details To View, Please Log In!");
} }
@Override @Override
public void deleteAccount() { public void deleteAccount() {
bankAccount = new BasicAccount(); bankAccount.changeBankAccountState(NotCreatedState.getInstance(bankAccount));
System.out.println("Account Deleted! We're Sad To See You Go :("); System.out.println("Account Deleted! We're Sad To See You Go :(");
// Same as?
// bankAccount = new BasicAccount();
// System.out.println("Account Deleted! We're Sad To See You Go :(");
} }
} }

@ -50,9 +50,7 @@ public class NotCreatedState implements BankAccountStates {
} }
@Override @Override
public void logIn() { public void logIn() { System.out.println("Sorry, Our Systems Couldn't Find Your Details. Please Try Again or Register!"); }
System.out.println("Sorry, Our Systems Couldn't Find Your Details. Please Try Again or Register!");
}
@Override @Override
public void logOut() { public void logOut() {
@ -71,9 +69,7 @@ public class NotCreatedState implements BankAccountStates {
} }
@Override @Override
public void viewDetails() { public void viewDetails() { System.out.println("There Are No Account Details To View, Please Log In or Register!"); }
System.out.println("There Are No Account Details To View, Please Log In or Register!");
}
@Override @Override
public void deleteAccount() { public void deleteAccount() {

Loading…
Cancel
Save