most Objects done
This commit is contained in:
@@ -29,7 +29,9 @@ public class ConsoleLib {
|
||||
userData[3] = sc.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
userData[2] = sc.nextLine();
|
||||
long id = AccountMgr.createWorker(userData,addressData);
|
||||
Address address = new Address(addressData[0],addressData[1],addressData[2],addressData[3]);
|
||||
Worker worker = new Worker(userData[0],userData[1],userData[2],userData[3],address);
|
||||
long id = AccountMgr.createWorker(worker);
|
||||
if(id < 1){
|
||||
System.out.println("Fehler beim erstellen");
|
||||
}
|
||||
@@ -56,7 +58,9 @@ public class ConsoleLib {
|
||||
userData[3] = sc.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
userData[2] = sc.nextLine();
|
||||
long id = AccountMgr.createParent(userData,addressData);
|
||||
Address address = new Address(addressData[0],addressData[1],addressData[2],addressData[3]);
|
||||
Parent parent = new Parent(userData[0],userData[1],userData[2],userData[3],address);
|
||||
long id = AccountMgr.createParent(parent);
|
||||
if(id < 1){
|
||||
System.out.println("Fehler beim erstellen");
|
||||
}
|
||||
@@ -88,7 +92,15 @@ public class ConsoleLib {
|
||||
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);
|
||||
Address address = AccountMgr.getAddressById(Long.parseLong(childData[2]));
|
||||
List<AllergySeverity> allergySeverities = new ArrayList<>();
|
||||
for(int i = 0; i < allergyData.length; i++){
|
||||
List<String> allergySeverity = Database.getEntryById("severity", Long.parseLong(severityData[i]));
|
||||
String[] asParts = allergySeverity.get(0).split(":");
|
||||
allergySeverities.add(new AllergySeverity(FoodMgr.getAllergyById(Long.parseLong(allergyData[0])),Long.parseLong(asParts[0]),asParts[1]));
|
||||
}
|
||||
Child child = new Child(childData[0],childData[1],address,allergySeverities);
|
||||
long id = AccountMgr.createChild(child);
|
||||
if(id < 1){
|
||||
System.out.println("Fehler beim erstellen");
|
||||
return;
|
||||
@@ -124,31 +136,34 @@ public class ConsoleLib {
|
||||
for (String data : allergyData) {
|
||||
allergyList.add(FoodMgr.getAllergyById(Long.parseLong(data)));
|
||||
}
|
||||
Food food = new Food(foodData[0],foodData[1],true,foodType,allergyList);
|
||||
boolean isDessert = !foodData[2].equals("0");
|
||||
Food food = new Food(foodData[0],foodData[1],isDessert,foodType,allergyList);
|
||||
if(FoodMgr.createFood(food) < 1){
|
||||
System.out.println("Fehler");
|
||||
}
|
||||
}
|
||||
|
||||
public static long loginPrompt(){
|
||||
public static User loginPrompt(){
|
||||
System.out.println("Login");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
long id = -1;
|
||||
while (id == -1){
|
||||
User user = null;
|
||||
while (user == null){
|
||||
System.out.print("Email: ");
|
||||
String email = sc.nextLine();
|
||||
if(email.isEmpty()){
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
System.out.print("Passwort: ");
|
||||
String pw = sc.nextLine();
|
||||
id = AccountMgr.login(email,pw);
|
||||
long id = AccountMgr.login(email,pw);
|
||||
if(id == -1){
|
||||
System.out.println("Login fehlgeschlagen");
|
||||
}else {
|
||||
user = AccountMgr.getUserById(id);
|
||||
}
|
||||
}
|
||||
System.out.println("Login erfolgreich");
|
||||
return id;
|
||||
return user;
|
||||
}
|
||||
|
||||
public static void matchParentChildPrompt(String parentId){
|
||||
@@ -193,12 +208,16 @@ public class ConsoleLib {
|
||||
System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: ");
|
||||
food_planData[0] = sc.nextLine();
|
||||
List<Food> veganMain = FoodMgr.getVeganFood(false);
|
||||
System.out.println(veganMain.size());
|
||||
for (Food food : veganMain) {
|
||||
System.out.println(food.getId() + " : " + food.getName());
|
||||
}
|
||||
System.out.print("Veganes Hauptgericht Nr: ");
|
||||
food_planData[1] = sc.nextLine();
|
||||
List<Food> foodMain = FoodMgr.getFood(false);
|
||||
for (Food food : foodMain) {
|
||||
System.out.println(food.getId() + " : " + food.getName());
|
||||
}
|
||||
System.out.print("Zweites Hauptgericht Nr: ");
|
||||
food_planData[2] = sc.nextLine();
|
||||
List<Food> veganDessert = FoodMgr.getVeganFood(true);
|
||||
@@ -213,7 +232,12 @@ public class ConsoleLib {
|
||||
}
|
||||
System.out.print("Zweites Dessert Nr: ");
|
||||
food_planData[4] = sc.nextLine();
|
||||
long id = FoodMgr.createFood_plan(food_planData);
|
||||
FoodPlan foodPlan = new FoodPlan(food_planData[0],
|
||||
FoodMgr.getFoodById(Long.parseLong(food_planData[1])),
|
||||
FoodMgr.getFoodById(Long.parseLong(food_planData[2])),
|
||||
FoodMgr.getFoodById(Long.parseLong(food_planData[3])),
|
||||
FoodMgr.getFoodById(Long.parseLong(food_planData[4])));
|
||||
long id = FoodMgr.createFood_plan(foodPlan);
|
||||
if(id < 0){
|
||||
System.out.println("Fehler");
|
||||
}
|
||||
@@ -224,29 +248,21 @@ public class ConsoleLib {
|
||||
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);
|
||||
FoodPlan plan = FoodMgr.getFoodPlan(date);
|
||||
List<String> foodList = new ArrayList<>();
|
||||
Food food;
|
||||
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]));
|
||||
sb.append(food.getName());
|
||||
sb.append(" Zweites Hauptgericht: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[3]));
|
||||
sb.append(food.getName());
|
||||
sb.append(" Veganesdessert: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[4]));
|
||||
sb.append(food.getName());
|
||||
sb.append(" Zweites Dessert: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[5]));
|
||||
sb.append(food.getName());
|
||||
foodList.add(sb.toString());
|
||||
}
|
||||
sb = new StringBuilder();
|
||||
sb.append("Tag: ");
|
||||
sb.append(plan.getDate());
|
||||
sb.append(" Veganesgericht: ");
|
||||
sb.append(plan.getFoodVegan().getName());
|
||||
sb.append(" Zweites Hauptgericht: ");
|
||||
sb.append(plan.getFoodSecond().getName());
|
||||
sb.append(" Veganesdessert: ");
|
||||
sb.append(plan.getDessertVegan().getName());
|
||||
sb.append(" Zweites Dessert: ");
|
||||
sb.append(plan.getDessertSecond().getName());
|
||||
foodList.add(sb.toString());
|
||||
printConsole(foodList);
|
||||
}
|
||||
|
||||
@@ -306,5 +322,6 @@ public class ConsoleLib {
|
||||
double price = sc.nextDouble();
|
||||
sc.nextLine();
|
||||
AccountMgr.price = price;
|
||||
AccountMgr.setPriceInDb();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user