Skip to content

Commit 7d91c15

Browse files
committed
Made the get method of the AccountContextFactory static.
1 parent c526d01 commit 7d91c15

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/main/java/Factory/AccountContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
77

88
public class AccountContextFactory {
9-
public AccountContext get(ContextType contextType) {
9+
static public AccountContext get(ContextType contextType) {
1010
switch (contextType) {
1111
case Memory:
1212
return new AccountMemoryContext();

src/main/java/UI/ConsoleApp.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
public class ConsoleApp {
1616
// we use a memory context here, but in production you would want to use the database context for instance
17-
AccountLogic accountLogic = new AccountLogic((new AccountContextFactory()).get(ContextType.Memory));
17+
AccountLogic accountLogic = new AccountLogic(AccountContextFactory.get(ContextType.Memory));
1818

1919
public void start() {
2020

21-
menu();
21+
printMenu();
2222
System.out.print("> ");
2323

2424
while (true) {
@@ -39,8 +39,8 @@ private ConsoleInput getInput() throws InvalidInputException {
3939

4040
private void handleInput(ConsoleInput input) throws UnknownCommandException, WrongArgumentsException {
4141
switch (input.getCommand()) {
42-
case "menu":
43-
menu();
42+
case "printMenu":
43+
printMenu();
4444
break;
4545

4646
case "register":
@@ -60,15 +60,15 @@ private void handleInput(ConsoleInput input) throws UnknownCommandException, Wro
6060
}
6161
}
6262

63-
private void menu() {
63+
private void printMenu() {
6464
System.out.println("Welcome to HashExample!");
6565
System.out.println("---------------------------------------------------------------");
6666
System.out.println("Register a new account using:");
6767
System.out.println(" register <username> <password>");
6868
System.out.println("Login to an existing account using:");
6969
System.out.println(" login <username> <password>");
7070
System.out.println();
71-
System.out.println("Type exit to close the application or type menu to see this menu again.");
71+
System.out.println("Type exit to close the application or type printMenu to see this printMenu again.");
7272
}
7373

7474
private void register(String args[]) throws WrongArgumentsException {

src/test/java/BLL/AccountLogicTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AccountLogicTest {
1616

1717
@BeforeEach
1818
public void initialize() {
19-
accountLogic = new AccountLogic((new AccountContextFactory()).get(ContextType.Memory));
19+
accountLogic = new AccountLogic(AccountContextFactory.get(ContextType.Memory));
2020

2121
try {
2222
accountLogic.register("abcdef", "1234567890");

0 commit comments

Comments
 (0)