2023-01-05 05:06:19 +01:00
|
|
|
package com.bib.essensbestellungsverwaltung;
|
2023-01-06 01:51:42 +01:00
|
|
|
/*
|
|
|
|
@author Malte Schulze Hobeling
|
|
|
|
*/
|
2023-01-05 05:06:19 +01:00
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
public class ConsoleMain {
|
2023-01-30 04:26:30 +01:00
|
|
|
static User currentUser = null;
|
|
|
|
static boolean running = true;
|
2023-01-05 05:06:19 +01:00
|
|
|
public static void main(String[] args) {
|
|
|
|
boolean firstRun = Database.init();
|
|
|
|
if(firstRun){
|
2023-01-07 23:14:41 +01:00
|
|
|
Database.createDb();
|
|
|
|
Database.fillDb();
|
2023-01-05 05:06:19 +01:00
|
|
|
ConsoleLib.createWorkerPrompt();
|
|
|
|
}
|
2023-01-30 04:26:30 +01:00
|
|
|
AccountMgr.getPriceFromDb();
|
|
|
|
while (running){
|
|
|
|
if(currentUser == null){
|
2023-01-05 05:06:19 +01:00
|
|
|
defaultMenu();
|
|
|
|
}else{
|
2023-01-30 04:26:30 +01:00
|
|
|
if(currentUser.getClass().getSimpleName().equals("Worker")){
|
2023-01-05 05:06:19 +01:00
|
|
|
adminMenu();
|
2023-01-30 04:26:30 +01:00
|
|
|
}else if(currentUser.getClass().getSimpleName().equals("Parent")){
|
2023-01-05 05:06:19 +01:00
|
|
|
parentMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void defaultMenu(){
|
2023-01-27 15:14:36 +01:00
|
|
|
System.out.println("0: Programm beenden");
|
2023-01-05 05:06:19 +01:00
|
|
|
System.out.println("1: Login");
|
|
|
|
System.out.println("2: Essensplan anzeigen");
|
2023-01-27 15:14:36 +01:00
|
|
|
System.out.println("3: Registrieren");
|
2023-01-05 05:06:19 +01:00
|
|
|
|
|
|
|
System.out.print("Auswahl: ");
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
String selection = sc.nextLine();
|
2023-01-06 01:51:42 +01:00
|
|
|
switch (selection) {
|
2023-01-30 04:26:30 +01:00
|
|
|
case "0" -> running = false;
|
2023-01-06 01:51:42 +01:00
|
|
|
case "1" -> {
|
2023-01-30 04:26:30 +01:00
|
|
|
currentUser = ConsoleLib.loginPrompt();
|
2023-01-06 01:51:42 +01:00
|
|
|
}
|
|
|
|
case "2" -> ConsoleLib.showFood_planPrompt();
|
2023-01-27 15:14:36 +01:00
|
|
|
case "3" -> ConsoleLib.createParentPrompt();
|
2023-01-05 05:06:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void adminMenu(){
|
|
|
|
System.out.println("0: Ausloggen");
|
|
|
|
System.out.println("1: Einen neuen Mitarbeiter anlegen");
|
|
|
|
System.out.println("2: Ein neues Elternteil anlegen");
|
|
|
|
System.out.println("3: Ein neues Kind anlegen");
|
|
|
|
System.out.println("4: Kind einem Elternteil zuordnen");
|
|
|
|
System.out.println("5: Ein neues Essen anlegen");
|
2023-01-27 15:14:36 +01:00
|
|
|
System.out.println("6: Einen Essensplan erstellen");
|
|
|
|
System.out.println("7: Essensplan anzeigen");
|
|
|
|
System.out.println("8: Essen auswählen");
|
|
|
|
System.out.println("9: Bestellungen des Tages sammeln");
|
|
|
|
System.out.println("10: Monatsabrechnung");
|
|
|
|
System.out.println("11: Preis ändern");
|
|
|
|
System.out.println("x1: Table");
|
|
|
|
System.out.println("x2: Löschen");
|
2023-01-05 05:06:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Auswahl: ");
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
String selection = sc.nextLine();
|
2023-01-06 01:51:42 +01:00
|
|
|
switch (selection) {
|
|
|
|
case "0" -> {
|
2023-01-30 04:26:30 +01:00
|
|
|
currentUser = null;
|
2023-01-06 01:51:42 +01:00
|
|
|
}
|
|
|
|
case "1" -> ConsoleLib.createWorkerPrompt();
|
|
|
|
case "2" -> ConsoleLib.createParentPrompt();
|
2023-01-30 04:26:30 +01:00
|
|
|
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUser.getId()));
|
|
|
|
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUser.getId()));
|
2023-01-06 01:51:42 +01:00
|
|
|
case "5" -> ConsoleLib.createFoodPrompt();
|
2023-01-27 15:14:36 +01:00
|
|
|
case "6" -> ConsoleLib.createFood_planPrompt();
|
|
|
|
case "7" -> ConsoleLib.showFood_planPrompt();
|
|
|
|
case "8" -> ConsoleLib.createFood_selectionPrompt();
|
|
|
|
case "9" -> ConsoleLib.dayOrderPrompt();
|
|
|
|
case "10" -> ConsoleLib.invoicePrompt();
|
|
|
|
case "11" -> ConsoleLib.changePricePrompt();
|
|
|
|
case "x1" -> ConsoleLib.tablePrompt();
|
|
|
|
case "x2" -> ConsoleLib.deletePrompt();
|
2023-01-05 05:06:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void parentMenu(){
|
|
|
|
System.out.println("0: Ausloggen");
|
|
|
|
System.out.println("3: Ein neues Kind anlegen");
|
2023-01-27 15:14:36 +01:00
|
|
|
System.out.println("7: Essensplan anzeigen");
|
|
|
|
System.out.println("8: Essen auswählen");
|
2023-01-05 05:06:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Auswahl: ");
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
String selection = sc.nextLine();
|
2023-01-06 01:51:42 +01:00
|
|
|
switch (selection) {
|
|
|
|
case "0" -> {
|
2023-01-30 04:26:30 +01:00
|
|
|
currentUser = null;
|
2023-01-06 01:51:42 +01:00
|
|
|
}
|
2023-01-30 04:26:30 +01:00
|
|
|
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUser.getId()));
|
2023-01-06 01:51:42 +01:00
|
|
|
case "6" -> ConsoleLib.tablePrompt();
|
2023-01-27 15:14:36 +01:00
|
|
|
case "7" -> ConsoleLib.showFood_planPrompt();
|
|
|
|
case "8" -> ConsoleLib.createFood_selectionPrompt();
|
2023-01-05 05:06:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|