Bestellungen: Bestand wird aktualisiert
parent
8aa7bbf465
commit
d0b4493755
|
|
@ -10,6 +10,7 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Bestellsystem {
|
||||
|
||||
private static List<Bestellung> bestellungen = new ArrayList<>();
|
||||
|
|
@ -50,16 +51,24 @@ public class Bestellsystem {
|
|||
boolean istVerfuegbar = false;
|
||||
if (gericht.equalsIgnoreCase("fertig")) {
|
||||
speichereBestellung(bestellung);
|
||||
System.out.println("Bestand wurde aktualisiert");
|
||||
break;
|
||||
}
|
||||
for (Dish dish : menu.getDishes()) {
|
||||
try { for (Dish dish : menu.getDishes()) {
|
||||
if (gericht.equalsIgnoreCase(dish.getName())) {
|
||||
SystemController.inventory.useIngredients(dish.getIngredients());
|
||||
bestellung.addGericht(gericht);
|
||||
istVerfuegbar = true;
|
||||
bestellungen.add(bestellung);
|
||||
System.out.println("Bestellung wurde aktualisiert");
|
||||
System.out.println(bestellung.getBestellungDetails());
|
||||
}
|
||||
|
||||
}
|
||||
// else {
|
||||
// System.out.println("Ist nicht verfügbar");
|
||||
// }
|
||||
}} catch (Exception e ) {
|
||||
|
||||
}
|
||||
if (istVerfuegbar == false) {
|
||||
System.out.println("Gericht ist nicht im Menu");
|
||||
|
|
@ -77,6 +86,7 @@ public class Bestellsystem {
|
|||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,9 +96,9 @@ public class Bestellsystem {
|
|||
File file = new File("src/Bestellungen.txt");
|
||||
FileWriter writer = new FileWriter(file, true);
|
||||
writer.write(bestellung.getBestellungDetails());
|
||||
LocalTime now = LocalTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
writer.write("\nZeit: " + now.format(formatter));
|
||||
LocalTime now = LocalTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
writer.write("\nZeit: " + now.format(formatter));
|
||||
writer.write("\n--------------------------\n");
|
||||
writer.close();
|
||||
System.out.println("Bestellung wurde erfolgreich gespeichert.");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
Tisch Nummer: 4444
|
||||
Bestellte Gerichte:
|
||||
|
||||
Zeit: 18:58
|
||||
--------------------------
|
||||
Tisch Nummer: 3333
|
||||
Bestellte Gerichte:
|
||||
- Ayrimramen
|
||||
- Cheeseburger
|
||||
|
||||
Zeit: 19:12
|
||||
--------------------------
|
||||
|
|
@ -33,7 +33,6 @@ class Inventory {
|
|||
writer.write(entry.getKey() + "," + entry.getValue());
|
||||
writer.newLine();
|
||||
}
|
||||
System.out.println("Bestand in Datei gespeichert.");
|
||||
} catch (IOException e) {
|
||||
System.out.println("Fehler beim Speichern der Datei: " + e.getMessage());
|
||||
}
|
||||
|
|
@ -49,8 +48,8 @@ class Inventory {
|
|||
System.out.println(entry.getKey() + ": " + entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean useIngredients(Map<String, Integer> ingredients) {
|
||||
|
||||
public boolean showIngredientsAvailable(Map<String, Integer> ingredients) {
|
||||
for (Map.Entry<String, Integer> entry : ingredients.entrySet()) {
|
||||
String ingredient = entry.getKey();
|
||||
int amount = entry.getValue();
|
||||
|
|
@ -59,10 +58,17 @@ class Inventory {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void useIngredients(Map<String, Integer> ingredients) {
|
||||
|
||||
for (Map.Entry<String, Integer> entry : ingredients.entrySet()) {
|
||||
stock.put(entry.getKey(), stock.get(entry.getKey()) - entry.getValue());
|
||||
saveStockToFile();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Neue Methode: Zutaten hinzufügen
|
||||
|
|
|
|||
|
|
@ -1,28 +1,43 @@
|
|||
import java.util.*;
|
||||
|
||||
class Menu {
|
||||
public List<Dish> dishes = new ArrayList<>();
|
||||
public List<Dish> dishes = new ArrayList<>();
|
||||
public List<Dish> availableDishes = new ArrayList<>();
|
||||
|
||||
public Menu() {
|
||||
public Menu() {
|
||||
|
||||
dishes.add(new Dish("Cheeseburger", Map.of("Brot", 1, "Fleisch", 1, "Käse", 1)));
|
||||
dishes.add(new Dish("Veggie-Burger", Map.of("Brot", 1, "Salat", 1, "Tomaten", 1)));
|
||||
dishes.add(new Dish("Double Meat Burger", Map.of("Brot", 1, "Fleisch", 2)));
|
||||
}
|
||||
dishes.add(new Dish("Cheeseburger", Map.of("Brot", 1, "Fleisch", 1, "Käse", 1)));
|
||||
dishes.add(new Dish("Veggie-Burger", Map.of("Brot", 1, "Salat", 1, "Tomaten", 1)));
|
||||
dishes.add(new Dish("Double Meat Burger", Map.of("Brot", 1, "Fleisch", 2)));
|
||||
dishes.add(new Dish("Ramen", Map.of("Soße", 1, "Salat", 1, "Tomaten", 1, "Nudeln", 30)));
|
||||
}
|
||||
|
||||
public void displayMenu(Inventory inventory) {
|
||||
System.out.println("Verfügbares Menü:");
|
||||
for (Dish dish : dishes) {
|
||||
if (inventory.useIngredients(dish.getIngredients()) == true) {
|
||||
System.out.println("- " + dish.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void displayMenu(Inventory inventory) {
|
||||
System.out.println("Verfügbares Menü:");
|
||||
for (Dish dish : dishes) {
|
||||
if (inventory.showIngredientsAvailable(dish.getIngredients()) == true) {
|
||||
System.out.println("- " + dish.getName());
|
||||
availableDishes.add(dish);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Dish> getAvailableDishes() {
|
||||
return availableDishes;
|
||||
}
|
||||
|
||||
public List<Dish> getDishes() {
|
||||
return dishes;
|
||||
}
|
||||
public void bestandMinus(Inventory inventory) {
|
||||
for (Dish dish : dishes) {
|
||||
inventory.useIngredients(dish.getIngredients());
|
||||
|
||||
public void setDishes(List<Dish> dishes) {
|
||||
this.dishes = dishes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Dish> getDishes() {
|
||||
return dishes;
|
||||
}
|
||||
|
||||
public void setDishes(List<Dish> dishes) {
|
||||
this.dishes = dishes;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ class SystemController {
|
|||
private Scanner scanner = new Scanner(System.in);
|
||||
private Map<String, User> users = new HashMap<>();
|
||||
private final String USERS_FILE = "src/users.txt";
|
||||
private Inventory inventory = new Inventory();
|
||||
public static Inventory inventory = new Inventory();
|
||||
private Menu menu = new Menu();
|
||||
|
||||
public SystemController() {
|
||||
|
|
@ -143,8 +143,8 @@ class SystemController {
|
|||
switch (choice) {
|
||||
case 1 -> {
|
||||
menu.displayMenu(inventory);
|
||||
|
||||
Bestellsystem.erstelleBestellung(); // Neue Bestellung erstellen
|
||||
|
||||
}
|
||||
case 2 -> {
|
||||
Bestellsystem.zeigeAlleBestellungen(); // Bestellungen im Speicher anzeigen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
Soße,50000000
|
||||
Soße,49999996
|
||||
Ananasdasdas,5000
|
||||
Brot,1532
|
||||
Tomaten,511
|
||||
Käse,732
|
||||
Fleisch,24
|
||||
Brot,1519
|
||||
Tomaten,503
|
||||
Käse,724
|
||||
Fleisch,12
|
||||
Salat,494
|
||||
|
|
|
|||
Loading…
Reference in New Issue