138 lines
4.2 KiB
Java
138 lines
4.2 KiB
Java
|
package com.bib.essensbestellungsverwaltung;
|
||
|
|
||
|
import java.util.List;
|
||
|
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();
|
||
|
Database.createDb();
|
||
|
Database.fillDb();
|
||
|
//Database.printSampleQuery();
|
||
|
if(firstRun){
|
||
|
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();
|
||
|
switch (selection){
|
||
|
case "1":
|
||
|
currentUserId = ConsoleLib.loginPrompt();
|
||
|
isWorker = AccountMgr.isWorker(String.valueOf(currentUserId));
|
||
|
isParent = AccountMgr.isParent(String.valueOf(currentUserId));
|
||
|
break;
|
||
|
case "2":
|
||
|
ConsoleLib.showFood_planPrompt();
|
||
|
break;
|
||
|
case "3":
|
||
|
currentUserId = -2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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");
|
||
|
|
||
|
|
||
|
System.out.print("Auswahl: ");
|
||
|
Scanner sc = new Scanner(System.in);
|
||
|
String selection = sc.nextLine();
|
||
|
switch (selection){
|
||
|
case "0":
|
||
|
currentUserId = -1;
|
||
|
isWorker = false;
|
||
|
isParent = false;
|
||
|
break;
|
||
|
case "1":
|
||
|
ConsoleLib.createWorkerPrompt();
|
||
|
break;
|
||
|
case "2":
|
||
|
ConsoleLib.createParentPrompt();
|
||
|
break;
|
||
|
case "3":
|
||
|
ConsoleLib.createChildPrompt(String.valueOf(currentUserId));
|
||
|
break;
|
||
|
case "4":
|
||
|
ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId));
|
||
|
break;
|
||
|
case "5":
|
||
|
ConsoleLib.createFoodPrompt();
|
||
|
break;
|
||
|
case "6":
|
||
|
ConsoleLib.tablePrompt();
|
||
|
break;
|
||
|
case "7":
|
||
|
ConsoleLib.createFood_planPrompt();
|
||
|
break;
|
||
|
case "8":
|
||
|
ConsoleLib.showFood_planPrompt();
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
switch (selection){
|
||
|
case "0":
|
||
|
currentUserId = -1;
|
||
|
isWorker = false;
|
||
|
isParent = false;
|
||
|
break;
|
||
|
case "3":
|
||
|
ConsoleLib.createChildPrompt(String.valueOf(currentUserId));
|
||
|
break;
|
||
|
case "4":
|
||
|
ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId));
|
||
|
break;
|
||
|
case "6":
|
||
|
ConsoleLib.tablePrompt();
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|