diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..bf2c501
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..5cb71ef
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a9076af
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..eba6e1f
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/dev/ui/ConsoleMenu.java b/src/main/java/dev/ui/ConsoleMenu.java
index 663dc0c..0ac17ee 100644
--- a/src/main/java/dev/ui/ConsoleMenu.java
+++ b/src/main/java/dev/ui/ConsoleMenu.java
@@ -1,44 +1,117 @@
package dev.ui;
+import dev.model.User;
+import dev.service.AuthService;
+import dev.service.MenuService;
+import dev.service.OrderService;
+
import java.util.Scanner;
public class ConsoleMenu {
- private final Scanner scanner =
- new Scanner(System.in);
+ private final Scanner scanner = new Scanner(System.in);
+
+ private final AuthService authService = new AuthService();
+
+ private final MenuService menuService = new MenuService();
+
+ private final OrderService orderService = new OrderService();
public void start() {
while (true) {
System.out.println();
- System.out.println("===== JAVA PIZZERIA =====");
- System.out.println("1. Login");
- System.out.println("2. Register");
- System.out.println("3. Exit");
+ System.out.println("===== RESTAURANT SYSTEM =====");
+ System.out.println("1. Register");
+ System.out.println("2. Login");
+ System.out.println("0. Exit");
+ System.out.print("Choose: ");
int choice = scanner.nextInt();
+ scanner.nextLine();
- switch (choice) {
-
- case 1:
- // TODO
- break;
-
- case 2:
- // TODO
- break;
-
- case 3:
- return;
-
- default:
- System.out.println("Invalid choice");
-
+ if (choice == 1) {
+ register();
+ } else if (choice == 2) {
+ login();
+ } else if (choice == 0) {
+ System.out.println("Goodbye!");
+ return;
+ } else {
+ System.out.println("Invalid choice.");
}
-
}
-
}
+ private void register() {
+
+ System.out.print("Username: ");
+ String username = scanner.nextLine();
+
+ System.out.print("Password: ");
+ String password = scanner.nextLine();
+
+ System.out.print("Email: ");
+ String email = scanner.nextLine();
+
+ boolean success = authService.register(username, password, email);
+
+ if (success) {
+ System.out.println("Registration successful.");
+ } else {
+ System.out.println("Registration failed.");
+ }
+ }
+
+ private void login() {
+
+ System.out.print("Username: ");
+ String username = scanner.nextLine();
+
+ System.out.print("Password: ");
+ String password = scanner.nextLine();
+
+ User user = authService.login(username, password);
+
+ if (user == null) {
+ System.out.println("Invalid username or password.");
+ return;
+ }
+
+ System.out.println("Login successful. Welcome " + user.getUsername());
+
+ userMenu(user);
+ }
+
+ private void userMenu(User user) {
+
+ while (true) {
+
+ System.out.println();
+ System.out.println("===== USER MENU =====");
+ System.out.println("1. View Menu");
+ System.out.println("2. Place Order");
+ System.out.println("3. Order History");
+ System.out.println("0. Logout");
+ System.out.print("Choose: ");
+
+ int choice = scanner.nextInt();
+ scanner.nextLine();
+
+ if (choice == 1) {
+ menuService.showMenu();
+ } else if (choice == 2) {
+ menuService.showMenu();
+ orderService.placeOrder(user.getId());
+ } else if (choice == 3) {
+ orderService.showOrderHistory(user.getId());
+ } else if (choice == 0) {
+ System.out.println("Logged out.");
+ return;
+ } else {
+ System.out.println("Invalid choice.");
+ }
+ }
+ }
}
\ No newline at end of file