diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 4d6bca8..39c0f6a 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -16,10 +16,10 @@ public static void main(String[] args){ GameMenu gameMenu = new GameMenu(scanner , new GameMenuController()); while(MenuName.getCurrentMenu() != MenuName.TERMINATE) { - LoginMenu.run(); - MainMenu.run(); - ProfileMenu.run(); - GameMenu.run(); + loginMenu.run(); + mainMenu.run(); + profileMenu.run(); + gameMenu.run(); } System.out.println("khaste nabashi ayoub jan!"); } diff --git a/src/main/java/View/GameMenu.java b/src/main/java/View/GameMenu.java index 321c7bc..c2257fc 100644 --- a/src/main/java/View/GameMenu.java +++ b/src/main/java/View/GameMenu.java @@ -7,16 +7,15 @@ import java.util.Scanner; import java.util.regex.Matcher; -public class GameMenu{ +public class GameMenu extends Menu{ private final GameMenuController gameMenuController; - private static Scanner scanner; public GameMenu(Scanner scanner, GameMenuController gameMenuController){ + super(scanner); this.gameMenuController = gameMenuController; - GameMenu.scanner = scanner; } - public static void run() { + public void run() { String input; Matcher matcher; diff --git a/src/main/java/View/LoginMenu.java b/src/main/java/View/LoginMenu.java index 44c3534..57bd33e 100644 --- a/src/main/java/View/LoginMenu.java +++ b/src/main/java/View/LoginMenu.java @@ -6,16 +6,15 @@ import java.util.Scanner; import java.util.regex.Matcher; -public class LoginMenu { +public class LoginMenu extends Menu{ private final LoginMenuController loginMenuController; - private static Scanner scanner; public LoginMenu(Scanner scanner , LoginMenuController loginMenuController) { - LoginMenu.scanner = scanner; + super(scanner); this.loginMenuController = loginMenuController; } - public static void run() { + public void run() { String input; Matcher matcher; diff --git a/src/main/java/View/MainMenu.java b/src/main/java/View/MainMenu.java index 571e751..b85fd8f 100644 --- a/src/main/java/View/MainMenu.java +++ b/src/main/java/View/MainMenu.java @@ -5,19 +5,19 @@ import java.util.Scanner; import java.util.regex.Matcher; -public class MainMenu { +public class MainMenu extends Menu{ private final MainMenuController mainMenuController; - private static Scanner scanner; + public MainMenu(Scanner scanner , MainMenuController mainMenuController) { - MainMenu.scanner = scanner; + super(scanner); this.mainMenuController = mainMenuController; } - public static void run() { + public void run() { String input; Matcher matcher; - while (MenuName.getCurrentMenu() == MenuName.MAIN_MENU) { + input = scanner.nextLine(); //TODO commands! } } diff --git a/src/main/java/View/Menu.java b/src/main/java/View/Menu.java new file mode 100644 index 0000000..a73ec79 --- /dev/null +++ b/src/main/java/View/Menu.java @@ -0,0 +1,12 @@ +package View; + +import java.util.Scanner; +import java.util.regex.Matcher; + +public abstract class Menu { + + protected Scanner scanner; + public abstract void run(); + + public Menu(Scanner scanner) {this.scanner = scanner;} +} diff --git a/src/main/java/View/ProfileMenu.java b/src/main/java/View/ProfileMenu.java index 3386b23..4017470 100644 --- a/src/main/java/View/ProfileMenu.java +++ b/src/main/java/View/ProfileMenu.java @@ -1,18 +1,23 @@ package View; import Controller.menu.ProfileMenuController; - +import Enum.MenuName; import java.util.Scanner; +import java.util.regex.Matcher; -public class ProfileMenu { +public class ProfileMenu extends Menu{ private final ProfileMenuController profileMenuController; private static Scanner scanner; public ProfileMenu(Scanner scanner, ProfileMenuController profileMenuController){ - ProfileMenu.scanner = scanner; + super(scanner); this.profileMenuController = profileMenuController; } - public static void run() { - + public void run() { + String input; + Matcher matcher; + while (MenuName.getCurrentMenu() == MenuName.PROFILE_MENU) { + input = scanner.nextLine(); + } } }