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 {
|
|
|
|
static long currentUserId = -1;
|
|
|
|
static boolean isWorker = false;
|
|
|
|
static boolean isParent = false;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
while (true){
|
|
|
|
if(currentUserId == -2){
|
|
|
|
break;
|
|
|
|
}else if(currentUserId < 0){
|
|
|
|
defaultMenu();
|
|
|
|
}else{
|
|
|
|
if(isWorker){
|
|
|
|
adminMenu();
|
|
|
|
}else if(isParent){
|
|
|
|
parentMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void defaultMenu(){
|
|
|
|
System.out.println("1: Login");
|
|
|
|
System.out.println("2: Essensplan anzeigen");
|
|
|
|
System.out.println("3: Programm beenden");
|
|
|
|
|
|
|
|
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 "1" -> {
|
2023-01-05 05:06:19 +01:00
|
|
|
currentUserId = ConsoleLib.loginPrompt();
|
|
|
|
isWorker = AccountMgr.isWorker(String.valueOf(currentUserId));
|
|
|
|
isParent = AccountMgr.isParent(String.valueOf(currentUserId));
|
2023-01-06 01:51:42 +01:00
|
|
|
}
|
|
|
|
case "2" -> ConsoleLib.showFood_planPrompt();
|
|
|
|
case "3" -> currentUserId = -2;
|
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");
|
|
|
|
System.out.println("6: Table");
|
|
|
|
System.out.println("7: Einen Essensplan erstellen");
|
|
|
|
System.out.println("8: Essensplan anzeigen");
|
2023-01-06 01:51:42 +01:00
|
|
|
System.out.println("9: Löschen");
|
|
|
|
System.out.println("10: Essen auswählen");
|
2023-01-07 23:14:41 +01:00
|
|
|
System.out.println("11: Bestellungen des Tages sammeln");
|
|
|
|
System.out.println("12: Monatsabrechnung");
|
|
|
|
System.out.println("13: Preis ändern");
|
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-05 05:06:19 +01:00
|
|
|
currentUserId = -1;
|
|
|
|
isWorker = false;
|
|
|
|
isParent = false;
|
2023-01-06 01:51:42 +01:00
|
|
|
}
|
|
|
|
case "1" -> ConsoleLib.createWorkerPrompt();
|
|
|
|
case "2" -> ConsoleLib.createParentPrompt();
|
|
|
|
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUserId));
|
|
|
|
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId));
|
|
|
|
case "5" -> ConsoleLib.createFoodPrompt();
|
|
|
|
case "6" -> ConsoleLib.tablePrompt();
|
|
|
|
case "7" -> ConsoleLib.createFood_planPrompt();
|
|
|
|
case "8" -> ConsoleLib.showFood_planPrompt();
|
|
|
|
case "9" -> ConsoleLib.deletePrompt();
|
|
|
|
case "10" -> ConsoleLib.createFood_selectionPrompt();
|
2023-01-07 23:14:41 +01:00
|
|
|
case "11" -> ConsoleLib.dayOrderPrompt();
|
|
|
|
case "12" -> ConsoleLib.invoicePrompt();
|
|
|
|
case "13" -> ConsoleLib.changePricePrompt();
|
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");
|
|
|
|
System.out.println("4: Kind einem Elternteil zuordnen");
|
|
|
|
|
|
|
|
|
|
|
|
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-05 05:06:19 +01:00
|
|
|
currentUserId = -1;
|
|
|
|
isWorker = false;
|
|
|
|
isParent = false;
|
2023-01-06 01:51:42 +01:00
|
|
|
}
|
|
|
|
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUserId));
|
|
|
|
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId));
|
|
|
|
case "6" -> ConsoleLib.tablePrompt();
|
|
|
|
default -> {
|
|
|
|
}
|
2023-01-05 05:06:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|