did some stuff
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
package com.bib.essensbestellungsverwaltung;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ConsoleLib {
|
||||
public static void createWorkerPrompt(){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.println("Registrierung eines neuen Mitarbeiters");
|
||||
String[] userData = new String[4];
|
||||
String[] addressData = new String[4];
|
||||
System.out.print("Nachname: ");
|
||||
userData[0] = sc.nextLine();
|
||||
System.out.print("Vorname: ");
|
||||
userData[1] = sc.nextLine();
|
||||
System.out.print("Straße: ");
|
||||
addressData[0] = sc.nextLine();
|
||||
System.out.print("Hausnummer: ");
|
||||
addressData[1] = sc.nextLine();
|
||||
System.out.print("Postleitzahl: ");
|
||||
addressData[2] = sc.nextLine();
|
||||
System.out.print("Stadt: ");
|
||||
addressData[3] = sc.nextLine();
|
||||
System.out.print("Email: ");
|
||||
userData[3] = sc.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
userData[2] = sc.nextLine();
|
||||
long id = AccountMgr.createWorker(userData,addressData);
|
||||
if(id < 1){
|
||||
System.out.println("Fehler beim erstellen");
|
||||
}
|
||||
}
|
||||
|
||||
public static void createParentPrompt(){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.println("Registrierung eines neuen Elternteils");
|
||||
String[] userData = new String[4];
|
||||
String[] addressData = new String[4];
|
||||
System.out.print("Nachname: ");
|
||||
userData[0] = sc.nextLine();
|
||||
System.out.print("Vorname: ");
|
||||
userData[1] = sc.nextLine();
|
||||
System.out.print("Straße: ");
|
||||
addressData[0] = sc.nextLine();
|
||||
System.out.print("Hausnummer: ");
|
||||
addressData[1] = sc.nextLine();
|
||||
System.out.print("Postleitzahl: ");
|
||||
addressData[2] = sc.nextLine();
|
||||
System.out.print("Stadt: ");
|
||||
addressData[3] = sc.nextLine();
|
||||
System.out.print("Email: ");
|
||||
userData[3] = sc.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
userData[2] = sc.nextLine();
|
||||
long id = AccountMgr.createParent(userData,addressData);
|
||||
if(id < 1){
|
||||
System.out.println("Fehler beim erstellen");
|
||||
}
|
||||
}
|
||||
|
||||
public static void createChildPrompt(String parentId){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String[] childData = new String[3];
|
||||
System.out.println("Registrierung eines neuen Kindes");
|
||||
System.out.print("Nachname: ");
|
||||
childData[0] = sc.nextLine();
|
||||
System.out.print("Vorname: ");
|
||||
childData[1] = sc.nextLine();
|
||||
System.out.println("Bitte geben Sie die Nummer der passenden Adresse an: ");
|
||||
for (String s : Database.getTable("address")) {
|
||||
String[] parts = s.split(":");
|
||||
System.out.printf("Nr.: %s Straße: %s Hausnr.: %s PLZ: %s Stadt: %s%n",parts[0],parts[1],parts[2],parts[3],parts[4]);
|
||||
}
|
||||
System.out.print("Adressnummer: ");
|
||||
childData[2] = sc.nextLine();
|
||||
for (String s : Database.getTable("allergy")) {
|
||||
String[] parts = s.split(":");
|
||||
System.out.printf("Nr. %s %s%n",parts[0],parts[1]);
|
||||
}
|
||||
System.out.println("Bitte Geben Sie die Nr der Allergien und Ihre Schwere an: ");
|
||||
System.out.print("Allergien (Nr mit , getrennt[1,4,5,16]): ");
|
||||
String allergies = sc.nextLine();
|
||||
String[] allergyData = allergies.split(",");
|
||||
System.out.print("Schweren (1 Harmlos - 3 Kritisch[2,3,1,3]): ");
|
||||
String severities = sc.nextLine();
|
||||
String[] severityData = severities.split(",");
|
||||
long id = AccountMgr.createChild(childData,allergyData,severityData);
|
||||
if(id < 1){
|
||||
System.out.println("Fehler beim erstellen");
|
||||
return;
|
||||
}
|
||||
String sId = String.valueOf(id);
|
||||
if(AccountMgr.matchParentChild(parentId,sId) == -1){
|
||||
System.out.println("Fehler beim verknüpfen");
|
||||
}
|
||||
}
|
||||
|
||||
public static void createFoodPrompt(){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String[] foodData = new String[4];
|
||||
System.out.println("Registrierung eines neuen Essens");
|
||||
System.out.print("Name: ");
|
||||
foodData[0] = sc.nextLine();
|
||||
System.out.print("Beschreibung: ");
|
||||
foodData[1] = sc.nextLine();
|
||||
System.out.print("Ist es ein Dessert?[0/1]: ");
|
||||
foodData[2] = sc.nextLine();
|
||||
System.out.print("Ist es vegan[1], vegetarisch[2] oder fleischhaltig[3]: ");
|
||||
foodData[3] = sc.nextLine();
|
||||
for (String s : Database.getTable("allergy")) {
|
||||
String[] parts = s.split(":");
|
||||
System.out.printf("Nr. %s %s%n",parts[0],parts[1]);
|
||||
}
|
||||
System.out.println("Bitte geben Sie die Nr. aller zutreffenden Allergien mit Komma getrennt an [1,3,6]");
|
||||
System.out.print("Allergienummer: ");
|
||||
String allergies = sc.nextLine();
|
||||
String[] allergyData = allergies.split(",");
|
||||
FoodMgr.createFood(foodData,allergyData);
|
||||
}
|
||||
|
||||
public static long loginPrompt(){
|
||||
System.out.println("Login");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
long id = -1;
|
||||
while (id == -1){
|
||||
System.out.print("Email: ");
|
||||
String email = sc.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
String pw = sc.nextLine();
|
||||
id = AccountMgr.login(email,pw);
|
||||
if(id == -1){
|
||||
System.out.println("Login fehlgeschlagen");
|
||||
}
|
||||
}
|
||||
System.out.println("Login erfolgreich");
|
||||
return id;
|
||||
}
|
||||
|
||||
public static void matchParentChildPrompt(String parentId){
|
||||
System.out.println("Wählen Sie ihr Kind aus: ");
|
||||
Database.getTable("child");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Nr: ");
|
||||
String childId = sc.nextLine();
|
||||
if(AccountMgr.matchParentChild(parentId,childId) == -1){
|
||||
System.out.println("Fehler");
|
||||
}
|
||||
}
|
||||
|
||||
public static void tablePrompt(){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Table: ");
|
||||
String table = sc.nextLine();
|
||||
printConsole(Database.getTable(table));
|
||||
}
|
||||
|
||||
public static void printConsole(List<String> list){
|
||||
for (String entry : list) {
|
||||
System.out.println(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public static void createFood_planPrompt(){
|
||||
System.out.println("Erstellen eines Essensplans");
|
||||
String[] food_planData = new String[5];
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: ");
|
||||
food_planData[0] = sc.nextLine();
|
||||
printConsole(FoodMgr.getVeganFood(false));
|
||||
System.out.print("Veganes Hauptgericht Nr: ");
|
||||
food_planData[1] = sc.nextLine();
|
||||
printConsole(FoodMgr.getFood(false));
|
||||
System.out.print("Zweites Hauptgericht Nr: ");
|
||||
food_planData[2] = sc.nextLine();
|
||||
printConsole(FoodMgr.getVeganFood(true));
|
||||
System.out.print("Veganes Dessert Nr: ");
|
||||
food_planData[3] = sc.nextLine();
|
||||
printConsole(FoodMgr.getFood(true));
|
||||
System.out.print("Zweites Dessert Nr: ");
|
||||
food_planData[4] = sc.nextLine();
|
||||
long id = FoodMgr.createFood_plan(food_planData);
|
||||
if(id < 0){
|
||||
System.out.println("Fehler");
|
||||
}
|
||||
}
|
||||
|
||||
public static void showFood_planPrompt(){
|
||||
System.out.println("Essensplan zum Anzeigen auswählen");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: ");
|
||||
String date = sc.nextLine();
|
||||
List<String> plan = FoodMgr.getFood_plan(date);
|
||||
List<String> food = new ArrayList<>();
|
||||
StringBuilder sb;
|
||||
for (String day : plan) {
|
||||
sb = new StringBuilder();
|
||||
String[] parts = day.split(":");
|
||||
sb.append("Tag: ");
|
||||
sb.append(parts[1]);
|
||||
sb.append(" Veganesgericht: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[2]));
|
||||
String[] foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
sb.append(" Zweites Hauptgericht: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[3]));
|
||||
foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
sb.append(" Veganesdessert: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[4]));
|
||||
foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
sb.append(" Zweites Dessert: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[5]));
|
||||
foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
food.add(sb.toString());
|
||||
}
|
||||
printConsole(food);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user