Food, User
This commit is contained in:
@@ -119,7 +119,13 @@ public class ConsoleLib {
|
||||
System.out.print("Allergienummer: ");
|
||||
String allergies = sc.nextLine();
|
||||
String[] allergyData = allergies.split(",");
|
||||
if(FoodMgr.createFood(foodData,allergyData) < 1){
|
||||
FoodType foodType = FoodMgr.getFoodTypeById(Long.parseLong(foodData[3]));
|
||||
List<Allergy> allergyList = new ArrayList<>();
|
||||
for (String data : allergyData) {
|
||||
allergyList.add(FoodMgr.getAllergyById(Long.parseLong(data)));
|
||||
}
|
||||
Food food = new Food(foodData[0],foodData[1],true,foodType,allergyList);
|
||||
if(FoodMgr.createFood(food) < 1){
|
||||
System.out.println("Fehler");
|
||||
}
|
||||
}
|
||||
@@ -131,6 +137,9 @@ public class ConsoleLib {
|
||||
while (id == -1){
|
||||
System.out.print("Email: ");
|
||||
String email = sc.nextLine();
|
||||
if(email.isEmpty()){
|
||||
return -1;
|
||||
}
|
||||
System.out.print("Passwort: ");
|
||||
String pw = sc.nextLine();
|
||||
id = AccountMgr.login(email,pw);
|
||||
@@ -183,16 +192,25 @@ public class ConsoleLib {
|
||||
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));
|
||||
List<Food> veganMain = FoodMgr.getVeganFood(false);
|
||||
for (Food food : veganMain) {
|
||||
System.out.println(food.getId() + " : " + food.getName());
|
||||
}
|
||||
System.out.print("Veganes Hauptgericht Nr: ");
|
||||
food_planData[1] = sc.nextLine();
|
||||
printConsole(FoodMgr.getFood(false));
|
||||
List<Food> foodMain = FoodMgr.getFood(false);
|
||||
System.out.print("Zweites Hauptgericht Nr: ");
|
||||
food_planData[2] = sc.nextLine();
|
||||
printConsole(FoodMgr.getVeganFood(true));
|
||||
List<Food> veganDessert = FoodMgr.getVeganFood(true);
|
||||
for (Food food : veganDessert) {
|
||||
System.out.println(food.getId() + " : " + food.getName());
|
||||
}
|
||||
System.out.print("Veganes Dessert Nr: ");
|
||||
food_planData[3] = sc.nextLine();
|
||||
printConsole(FoodMgr.getFood(true));
|
||||
List<Food> foodDessert = FoodMgr.getFood(true);
|
||||
for (Food food : foodDessert) {
|
||||
System.out.println(food.getId() + " : " + food.getName());
|
||||
}
|
||||
System.out.print("Zweites Dessert Nr: ");
|
||||
food_planData[4] = sc.nextLine();
|
||||
long id = FoodMgr.createFood_plan(food_planData);
|
||||
@@ -207,7 +225,8 @@ public class ConsoleLib {
|
||||
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<>();
|
||||
List<String> foodList = new ArrayList<>();
|
||||
Food food;
|
||||
StringBuilder sb;
|
||||
for (String day : plan) {
|
||||
sb = new StringBuilder();
|
||||
@@ -216,23 +235,19 @@ public class ConsoleLib {
|
||||
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(food.getName());
|
||||
sb.append(" Zweites Hauptgericht: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[3]));
|
||||
foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
sb.append(food.getName());
|
||||
sb.append(" Veganesdessert: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[4]));
|
||||
foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
sb.append(food.getName());
|
||||
sb.append(" Zweites Dessert: ");
|
||||
food = FoodMgr.getFoodById(Long.parseLong(parts[5]));
|
||||
foodParts = food.get(0).split(":");
|
||||
sb.append(foodParts[1]);
|
||||
food.add(sb.toString());
|
||||
sb.append(food.getName());
|
||||
foodList.add(sb.toString());
|
||||
}
|
||||
printConsole(food);
|
||||
printConsole(foodList);
|
||||
}
|
||||
|
||||
public static void createFood_selectionPrompt(){
|
||||
|
||||
Reference in New Issue
Block a user