Merge von Finanzverwaltung (Arim) und Restaurantverwaltung (Abbas)
commit
953529616c
|
|
@ -24,72 +24,45 @@ public class Bestellsystem {
|
||||||
System.out.print("Bitte gib die Tischnummer ein: ");
|
System.out.print("Bitte gib die Tischnummer ein: ");
|
||||||
String tischNummer = scanner.nextLine();
|
String tischNummer = scanner.nextLine();
|
||||||
Bestellung bestellung = new Bestellung(tischNummer);
|
Bestellung bestellung = new Bestellung(tischNummer);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// List<Dish> Gerichte = new ArrayList<>(menu.getDishes());
|
// Gericht auswählen
|
||||||
// try (BufferedReader reader = new BufferedReader(new FileReader(STOCK_FILE))) {
|
|
||||||
// String line;
|
|
||||||
// while ((line = reader.readLine()) != null) {
|
|
||||||
// String[] parts = line.split(",");
|
|
||||||
//
|
|
||||||
// String name = parts[0];
|
|
||||||
// Integer count = Integer.parseInt(parts[1]);
|
|
||||||
// stock.put(name, count);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// } catch (FileNotFoundException e) {
|
|
||||||
// System.out.println("Stockdatenbank nicht gefunden. Einträge müssen manuell erstellt werden");
|
|
||||||
//
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// System.out.println("Fehler beim Lesen der Benutzerdatenbank: " + e.getMessage());
|
|
||||||
// }
|
|
||||||
// for (Dish gericht : Gerichte) {
|
|
||||||
// if (stock.containsKey(gericht.getName())) {
|
|
||||||
// if (stock.get(gericht.getName()) < )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
System.out.print("Bitte bestelle ein Gericht (oder 'fertig', um abzuschließen): ");
|
System.out.print("Bitte bestelle ein Gericht (oder 'fertig', um abzuschließen): ");
|
||||||
String gericht = scanner.nextLine();
|
String gericht = scanner.nextLine();
|
||||||
boolean istVerfuegbar = false;
|
boolean istVerfuegbar = false;
|
||||||
|
|
||||||
|
// Wenn der Benutzer 'fertig' eingibt, wird die Bestellung gespeichert
|
||||||
if (gericht.equalsIgnoreCase("fertig")) {
|
if (gericht.equalsIgnoreCase("fertig")) {
|
||||||
speichereBestellung(bestellung);
|
speichereBestellung(bestellung);
|
||||||
System.out.println("Bestand wurde aktualisiert");
|
System.out.println("Bestand wurde aktualisiert");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try { for (Dish dish : menu.getDishes()) {
|
|
||||||
|
// Überprüfen, ob das Gericht im Menü verfügbar ist
|
||||||
|
try {
|
||||||
|
for (Dish dish : menu.getDishes()) {
|
||||||
if (gericht.equalsIgnoreCase(dish.getName())) {
|
if (gericht.equalsIgnoreCase(dish.getName())) {
|
||||||
|
// Zutaten für das Gericht verwenden (Bestand aktualisieren)
|
||||||
SystemController.inventory.useIngredients(dish.getIngredients());
|
SystemController.inventory.useIngredients(dish.getIngredients());
|
||||||
bestellung.addGericht(gericht);
|
bestellung.addGericht(gericht); // Gericht zur Bestellung hinzufügen
|
||||||
istVerfuegbar = true;
|
istVerfuegbar = true;
|
||||||
bestellungen.add(bestellung);
|
bestellungen.add(bestellung); // Bestellung zur Liste der Bestellungen hinzufügen
|
||||||
System.out.println("Bestellung wurde aktualisiert");
|
System.out.println("Bestellung wurde aktualisiert");
|
||||||
System.out.println(bestellung.getBestellungDetails());
|
System.out.println(bestellung.getBestellungDetails()); // Bestellungsdetails anzeigen
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// System.out.println("Ist nicht verfügbar");
|
|
||||||
// }
|
|
||||||
}} catch (Exception e ) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (istVerfuegbar == false) {
|
} catch (Exception e) {
|
||||||
System.out.println("Gericht ist nicht im Menu");
|
System.out.println("Fehler beim Hinzufügen des Gerichts zur Bestellung: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// while (true) {
|
// Wenn das Gericht nicht im Menü ist, eine Fehlermeldung anzeigen
|
||||||
// System.out.print("Möchte der Kunde noch einen Zusatzwunsch für dieses Gericht? (ja/nein): ");
|
if (!istVerfuegbar) {
|
||||||
// String wunschAntwort = scanner.nextLine();
|
System.out.println("Gericht ist nicht im Menü.");
|
||||||
//
|
}
|
||||||
// if (wunschAntwort.equalsIgnoreCase("ja")) {
|
}
|
||||||
// System.out.print("Bitte gib den Zusatzwunsch ein (z.B. 'keine Tomaten'): ");
|
}
|
||||||
// String zusatzWunsch = scanner.nextLine();
|
|
||||||
// bestellung.addZusatzWunsch(zusatzWunsch);
|
|
||||||
// } else if (wunschAntwort.equalsIgnoreCase("nein")) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loescheBestellung() {
|
public static void loescheBestellung() {
|
||||||
ladeUndZeigeBestellungen();
|
ladeUndZeigeBestellungen();
|
||||||
|
|
@ -114,6 +87,7 @@ public class Bestellsystem {
|
||||||
System.out.println("Keine Bestellung mit der angegebenen ID gefunden.");
|
System.out.println("Keine Bestellung mit der angegebenen ID gefunden.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void aktualisiereDatei() {
|
private static void aktualisiereDatei() {
|
||||||
try (FileWriter writer = new FileWriter(FILE_PATH, false)) {
|
try (FileWriter writer = new FileWriter(FILE_PATH, false)) {
|
||||||
for (Bestellung bestellung : bestellungen) {
|
for (Bestellung bestellung : bestellungen) {
|
||||||
|
|
@ -124,7 +98,6 @@ public class Bestellsystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void speichereBestellung(Bestellung bestellung) {
|
public static void speichereBestellung(Bestellung bestellung) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,37 @@ Bestellte Gerichte:
|
||||||
|
|
||||||
Zeit: 16:13
|
Zeit: 16:13
|
||||||
--------------------------
|
--------------------------
|
||||||
|
ID: 657b07cf-3416-43a6-9477-8f057541caeb
|
||||||
|
Tisch Nummer: 01
|
||||||
|
Bestellte Gerichte:
|
||||||
|
|
||||||
|
Zeit: 17:13
|
||||||
|
--------------------------
|
||||||
|
ID: 13b6908f-6b5e-4ed5-9d83-a01913bf0608
|
||||||
|
Tisch Nummer: Ramen
|
||||||
|
Bestellte Gerichte:
|
||||||
|
|
||||||
|
Zeit: 17:25
|
||||||
|
--------------------------
|
||||||
|
ID: dbe203a2-da99-4420-8095-999f79d37eaa
|
||||||
|
Tisch Nummer: Cheeseburger
|
||||||
|
Bestellte Gerichte:
|
||||||
|
|
||||||
|
Zeit: 17:28
|
||||||
|
--------------------------
|
||||||
|
ID: f72aa0bf-d739-4e72-9654-add74abc3cea
|
||||||
|
Tisch Nummer: 01
|
||||||
|
Bestellte Gerichte:
|
||||||
|
- Cheeseburger
|
||||||
|
- Ramen
|
||||||
|
- Ramen
|
||||||
|
|
||||||
|
Zeit: 17:33
|
||||||
|
--------------------------
|
||||||
|
ID: 8adf6247-e041-46fd-86ee-2773b2eb69fe
|
||||||
|
Tisch Nummer: 01
|
||||||
|
Bestellte Gerichte:
|
||||||
|
- Cheeseburger
|
||||||
|
|
||||||
|
Zeit: 17:42
|
||||||
|
--------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
|
|
||||||
class Dish {
|
class Dish {
|
||||||
private String name;
|
private String name;
|
||||||
private Map<String, Integer> ingredients;
|
private Map<String, Integer> ingredients;
|
||||||
|
private double price; // Preis für jedes Gericht
|
||||||
|
|
||||||
public Dish(String name, Map<String, Integer> ingredients) {
|
public Dish(String name, Map<String, Integer> ingredients, double price) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
@ -15,4 +18,8 @@ class Dish {
|
||||||
public Map<String, Integer> getIngredients() {
|
public Map<String, Integer> getIngredients() {
|
||||||
return ingredients;
|
return ingredients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,144 +1,92 @@
|
||||||
import java.io.*;
|
import java.time.LocalDate;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.HashMap;
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
|
|
||||||
class FinancialManager {
|
public class FinancialManager {
|
||||||
private static final String TRANSACTION_FILE = "src/transactions.txt"; // Datei für Transaktionen (Einnahmen und Ausgaben)
|
private double totalRevenue;
|
||||||
private List<Transaction> transactions = new ArrayList<>();
|
private double totalExpenses;
|
||||||
|
private double totalProfit;
|
||||||
|
private Map<LocalDate, Double> dailyRevenue = new HashMap<>();
|
||||||
|
private Map<LocalDate, Double> weeklyRevenue = new HashMap<>();
|
||||||
|
private Map<LocalDate, Double> monthlyRevenue = new HashMap<>();
|
||||||
|
private Map<LocalDate, Double> dailyExpenses = new HashMap<>();
|
||||||
|
private Map<LocalDate, Double> weeklyExpenses = new HashMap<>();
|
||||||
|
private Map<LocalDate, Double> monthlyExpenses = new HashMap<>();
|
||||||
|
|
||||||
public FinancialManager() {
|
// Methode zur Hinzufügung von Einnahmen
|
||||||
loadTransactionsFromFile();
|
public void addRevenue(double amount) {
|
||||||
|
this.totalRevenue += amount;
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
dailyRevenue.put(today, dailyRevenue.getOrDefault(today, 0.0) + amount);
|
||||||
|
|
||||||
|
// Einnahmen für die Woche und den Monat aktualisieren
|
||||||
|
LocalDate startOfWeek = today.minusDays(today.getDayOfWeek().getValue() - 1);
|
||||||
|
weeklyRevenue.put(startOfWeek, weeklyRevenue.getOrDefault(startOfWeek, 0.0) + amount);
|
||||||
|
|
||||||
|
LocalDate startOfMonth = today.withDayOfMonth(1);
|
||||||
|
monthlyRevenue.put(startOfMonth, monthlyRevenue.getOrDefault(startOfMonth, 0.0) + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordTransaction(double amount, String description, boolean isIncome) {
|
// Methode zur Hinzufügung von Ausgaben
|
||||||
Date date = new Date();
|
public void addExpense(double amount) {
|
||||||
Transaction transaction = new Transaction(amount, description, isIncome, date);
|
this.totalExpenses += amount;
|
||||||
transactions.add(transaction);
|
LocalDate today = LocalDate.now();
|
||||||
saveTransactionToFile(transaction);
|
dailyExpenses.put(today, dailyExpenses.getOrDefault(today, 0.0) + amount);
|
||||||
|
|
||||||
|
// Ausgaben für die Woche und den Monat aktualisieren
|
||||||
|
LocalDate startOfWeek = today.minusDays(today.getDayOfWeek().getValue() - 1);
|
||||||
|
weeklyExpenses.put(startOfWeek, weeklyExpenses.getOrDefault(startOfWeek, 0.0) + amount);
|
||||||
|
|
||||||
|
LocalDate startOfMonth = today.withDayOfMonth(1);
|
||||||
|
monthlyExpenses.put(startOfMonth, monthlyExpenses.getOrDefault(startOfMonth, 0.0) + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveTransactionToFile(Transaction transaction) {
|
// Methode zur Berechnung der Einnahmen für einen bestimmten Zeitraum
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(TRANSACTION_FILE, true))) {
|
public double getRevenueForPeriod(String period) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
LocalDate today = LocalDate.now();
|
||||||
String transactionLine = dateFormat.format(transaction.getDate()) + ";" + transaction.getAmount() + ";" + transaction.getDescription() + ";" + (transaction.isIncome() ? "Income" : "Expense");
|
|
||||||
writer.write(transactionLine);
|
|
||||||
writer.newLine();
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("Fehler beim Speichern der Transaktion: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadTransactionsFromFile() {
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(TRANSACTION_FILE))) {
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
String[] parts = line.split(";");
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
Date date = dateFormat.parse(parts[0]);
|
|
||||||
double amount = Double.parseDouble(parts[1]);
|
|
||||||
String description = parts[2];
|
|
||||||
boolean isIncome = "Income".equals(parts[3]);
|
|
||||||
transactions.add(new Transaction(amount, description, isIncome, date));
|
|
||||||
}
|
|
||||||
} catch (IOException | java.text.ParseException e) {
|
|
||||||
System.out.println("Fehler beim Laden der Transaktionen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showFinancialReport(String period) {
|
|
||||||
double totalIncome = 0;
|
|
||||||
double totalExpense = 0;
|
|
||||||
Date startDate = null;
|
|
||||||
Date endDate = new Date();
|
|
||||||
|
|
||||||
switch (period.toLowerCase()) {
|
switch (period.toLowerCase()) {
|
||||||
case "daily":
|
case "daily":
|
||||||
startDate = getStartOfDay();
|
return dailyRevenue.getOrDefault(today, 0.0);
|
||||||
break;
|
|
||||||
case "weekly":
|
case "weekly":
|
||||||
startDate = getStartOfWeek();
|
LocalDate startOfWeek = today.minusDays(today.getDayOfWeek().getValue() - 1);
|
||||||
break;
|
return weeklyRevenue.getOrDefault(startOfWeek, 0.0);
|
||||||
case "monthly":
|
case "monthly":
|
||||||
startDate = getStartOfMonth();
|
LocalDate startOfMonth = today.withDayOfMonth(1);
|
||||||
break;
|
return monthlyRevenue.getOrDefault(startOfMonth, 0.0);
|
||||||
default:
|
default:
|
||||||
System.out.println("Ungültige Zeitraumoption!");
|
return 0.0;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Berechnen der Einnahmen und Ausgaben im angegebenen Zeitraum
|
|
||||||
for (Transaction transaction : transactions) {
|
|
||||||
if (!transaction.getDate().before(startDate) && !transaction.getDate().after(endDate)) {
|
|
||||||
if (transaction.isIncome()) {
|
|
||||||
totalIncome += transaction.getAmount();
|
|
||||||
} else {
|
|
||||||
totalExpense += transaction.getAmount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("\n--- Finanzbericht für " + period + " ---");
|
// Methode zur Berechnung der Ausgaben für einen bestimmten Zeitraum
|
||||||
System.out.println("Gesamte Einnahmen: " + totalIncome + " EUR");
|
public double getExpensesForPeriod(String period) {
|
||||||
System.out.println("Gesamte Ausgaben: " + totalExpense + " EUR");
|
LocalDate today = LocalDate.now();
|
||||||
System.out.println("Nettogewinn: " + (totalIncome - totalExpense) + " EUR");
|
switch (period.toLowerCase()) {
|
||||||
|
case "daily":
|
||||||
|
return dailyExpenses.getOrDefault(today, 0.0);
|
||||||
|
case "weekly":
|
||||||
|
LocalDate startOfWeek = today.minusDays(today.getDayOfWeek().getValue() - 1);
|
||||||
|
return weeklyExpenses.getOrDefault(startOfWeek, 0.0);
|
||||||
|
case "monthly":
|
||||||
|
LocalDate startOfMonth = today.withDayOfMonth(1);
|
||||||
|
return monthlyExpenses.getOrDefault(startOfMonth, 0.0);
|
||||||
|
default:
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getStartOfDay() {
|
// Getter für Gesamtumsatz
|
||||||
Calendar cal = Calendar.getInstance();
|
public double getTotalRevenue() {
|
||||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
return totalRevenue;
|
||||||
cal.set(Calendar.MINUTE, 0);
|
|
||||||
cal.set(Calendar.SECOND, 0);
|
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getStartOfWeek() {
|
// Getter für Gesamtausgaben
|
||||||
Calendar cal = Calendar.getInstance();
|
public double getTotalExpenses() {
|
||||||
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
return totalExpenses;
|
||||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
cal.set(Calendar.MINUTE, 0);
|
|
||||||
cal.set(Calendar.SECOND, 0);
|
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getStartOfMonth() {
|
// Berechnung des Nettogewinns
|
||||||
Calendar cal = Calendar.getInstance();
|
public double getNetProfit() {
|
||||||
cal.set(Calendar.DAY_OF_MONTH, 1);
|
return totalRevenue - totalExpenses;
|
||||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
cal.set(Calendar.MINUTE, 0);
|
|
||||||
cal.set(Calendar.SECOND, 0);
|
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Transaction {
|
|
||||||
private double amount;
|
|
||||||
private String description;
|
|
||||||
private boolean isIncome;
|
|
||||||
private Date date;
|
|
||||||
|
|
||||||
public Transaction(double amount, String description, boolean isIncome, Date date) {
|
|
||||||
this.amount = amount;
|
|
||||||
this.description = description;
|
|
||||||
this.isIncome = isIncome;
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAmount() {
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIncome() {
|
|
||||||
return isIncome;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,129 +1,141 @@
|
||||||
import java.util.*;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
class Inventory {
|
public class Inventory {
|
||||||
private Map<String, Integer> stock;
|
|
||||||
private final String STOCK_FILE = "src/stock.txt";
|
|
||||||
|
|
||||||
|
private Map<String, Integer> stock = new HashMap<>();
|
||||||
|
private FinancialManager financialManager; // Deklaration der Instanzvariable
|
||||||
|
|
||||||
|
public Inventory(FinancialManager financialManager) {
|
||||||
|
this.financialManager = financialManager; // Initialisierung des FinancialManagers im Konstruktor
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String STOCK_FILE = "src/stock.txt"; // Datei für den Bestand
|
||||||
|
|
||||||
|
// Lädt den Bestand aus der Datei
|
||||||
public void loadStockFromFile() {
|
public void loadStockFromFile() {
|
||||||
stock = new HashMap<>();
|
stock.clear();
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(STOCK_FILE))) {
|
try (BufferedReader reader = new BufferedReader(new FileReader(STOCK_FILE))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
String[] parts = line.split(",");
|
String[] parts = line.split(":");
|
||||||
|
if (parts.length == 2) {
|
||||||
String name = parts[0];
|
String ingredientName = parts[0];
|
||||||
Integer count = Integer.parseInt(parts[1]);
|
int quantity = Integer.parseInt(parts[1]);
|
||||||
stock.put(name, count);
|
stock.put(ingredientName, quantity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("Stockdatenbank nicht gefunden. Einträge müssen manuell erstellt werden");
|
System.out.println("Bestand-Datei nicht gefunden, neue Datei wird erstellt.");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Fehler beim Lesen der Benutzerdatenbank: " + e.getMessage());
|
System.out.println("Fehler beim Laden des Bestands: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Speichert den aktuellen Bestand in die Datei
|
||||||
public void saveStockToFile() {
|
public void saveStockToFile() {
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(STOCK_FILE))) {
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(STOCK_FILE))) {
|
||||||
for (Map.Entry<String, Integer> entry : stock.entrySet()) {
|
for (Map.Entry<String, Integer> entry : stock.entrySet()) {
|
||||||
writer.write(entry.getKey() + "," + entry.getValue());
|
writer.write(entry.getKey() + ":" + entry.getValue());
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Fehler beim Speichern der Datei: " + e.getMessage());
|
System.out.println("Fehler beim Speichern des Bestands: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory() {
|
// Zeigt den aktuellen Bestand an
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void viewStock() {
|
public void viewStock() {
|
||||||
System.out.println("Aktueller Bestand:");
|
if (stock.isEmpty()) {
|
||||||
|
System.out.println("Der Bestand ist leer.");
|
||||||
|
} else {
|
||||||
|
System.out.println("\n--- Aktueller Bestand ---");
|
||||||
for (Map.Entry<String, Integer> entry : stock.entrySet()) {
|
for (Map.Entry<String, Integer> entry : stock.entrySet()) {
|
||||||
System.out.println(entry.getKey() + ": " + entry.getValue());
|
System.out.println(entry.getKey() + ": " + entry.getValue() + " Stück");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bestellmenge verringern (z.B. beim Bestellen)
|
||||||
|
public void useIngredients(Map<String, Integer> usedIngredients) {
|
||||||
|
for (Map.Entry<String, Integer> entry : usedIngredients.entrySet()) {
|
||||||
|
String ingredientName = entry.getKey();
|
||||||
|
int amountUsed = entry.getValue();
|
||||||
|
if (stock.containsKey(ingredientName)) {
|
||||||
|
int currentStock = stock.get(ingredientName);
|
||||||
|
if (currentStock >= amountUsed) {
|
||||||
|
stock.put(ingredientName, currentStock - amountUsed);
|
||||||
|
} else {
|
||||||
|
System.out.println("Nicht genügend Bestand für " + ingredientName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Zutat " + ingredientName + " existiert nicht im Bestand.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bestand erweitern und berechnen, ob Ausgaben hinzuzufügen sind
|
||||||
|
public void addIngredients(String productName, int amountToAdd, FinancialManager financialManager) {
|
||||||
|
double ingredientCost = 1.0; // Beispielhafter Preis für Zutaten (z.B. 1 Euro pro Stück)
|
||||||
|
|
||||||
|
// Addiere die Zutaten zum Bestand
|
||||||
|
stock.put(productName, stock.getOrDefault(productName, 0) + amountToAdd);
|
||||||
|
|
||||||
|
// Berechne die Ausgaben für die Erweiterung des Bestands
|
||||||
|
double totalCost = ingredientCost * amountToAdd;
|
||||||
|
|
||||||
|
// Gebe die Kosten in den Finanzen an
|
||||||
|
financialManager.addExpense(totalCost);
|
||||||
|
|
||||||
|
System.out.println("Bestand für " + productName + " wurde um " + amountToAdd + " Stück erhöht.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gibt den Preis für eine bestimmte Zutat zurück (Beispielpreise)
|
||||||
|
private double getPriceForIngredient(String ingredientName) {
|
||||||
|
switch (ingredientName.toLowerCase()) {
|
||||||
|
case "salat":
|
||||||
|
return 1.5; // Preis für Salat pro Einheit
|
||||||
|
case "tomaten":
|
||||||
|
return 0.8; // Preis für Tomaten pro Einheit
|
||||||
|
case "cheeseburger":
|
||||||
|
return 3.0; // Preis für Cheeseburger pro Einheit
|
||||||
|
default:
|
||||||
|
return 1.0; // Standardpreis pro Einheit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In der Inventory-Klasse:
|
||||||
public boolean showIngredientsAvailable(Map<String, Integer> ingredients) {
|
public boolean showIngredientsAvailable(Map<String, Integer> ingredients) {
|
||||||
for (Map.Entry<String, Integer> entry : ingredients.entrySet()) {
|
for (Map.Entry<String, Integer> entry : ingredients.entrySet()) {
|
||||||
String ingredient = entry.getKey();
|
String ingredient = entry.getKey();
|
||||||
int amount = entry.getValue();
|
int requiredAmount = entry.getValue();
|
||||||
|
|
||||||
if (!stock.containsKey(ingredient) || stock.get(ingredient) < amount) {
|
// Überprüfe, ob der Lagerbestand ausreicht
|
||||||
|
if (!stock.containsKey(ingredient) || stock.get(ingredient) < requiredAmount) {
|
||||||
|
System.out.println("Nicht genügend Bestand für: " + ingredient); // Fehlermeldung
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void useIngredients(Map<String, Integer> ingredients) {
|
|
||||||
|
|
||||||
for (Map.Entry<String, Integer> entry : ingredients.entrySet()) {
|
public void overwriteStock(String productName, int newAmount) {
|
||||||
stock.put(entry.getKey(), stock.get(entry.getKey()) - entry.getValue());
|
if (stock.containsKey(productName)) {
|
||||||
saveStockToFile();
|
stock.put(productName, newAmount);
|
||||||
}
|
System.out.println("Der Bestand für " + productName + " wurde auf " + newAmount + " Stück geändert.");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neue Methode: Zutaten hinzufügen
|
|
||||||
public void addIngredients(String ingredient, int amount) {
|
|
||||||
if (amount <= 0) {
|
|
||||||
System.out.println("Ungültige Menge: " + amount);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
stock.put(ingredient, stock.getOrDefault(ingredient, 0) + amount);
|
|
||||||
System.out.println(amount + " " + ingredient + " hinzugefügt.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neue Methode: Zutaten entfernen
|
|
||||||
public void removeIngredient(String ingredient) {
|
|
||||||
if (stock.containsKey(ingredient)) {
|
|
||||||
stock.remove(ingredient);
|
|
||||||
System.out.println(ingredient + " wurde aus dem Lager entfernt.");
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println(ingredient + " ist nicht im Lager vorhanden.");
|
System.out.println("Das Produkt " + productName + " existiert nicht im Bestand.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Neue Methode: Gesamten Bestand prüfen
|
// Getter für den Bestand
|
||||||
public int totalStock() {
|
public Map<String, Integer> getStock() {
|
||||||
int total = 0;
|
return stock;
|
||||||
for (int amount : stock.values()) {
|
|
||||||
total += amount;
|
|
||||||
}
|
|
||||||
return total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Neue Methode: Warnungen bei niedrigem Bestand
|
// Setter für den Bestand
|
||||||
public void lowStockWarning(int threshold) {
|
public void setStock(Map<String, Integer> stock) {
|
||||||
System.out.println("Warnung: Niedriger Bestand bei folgenden Zutaten:");
|
this.stock = stock;
|
||||||
for (Map.Entry<String, Integer> entry : stock.entrySet()) {
|
|
||||||
if (entry.getValue() < threshold) {
|
|
||||||
System.out.println(entry.getKey() + ": " + entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Neue Methode: Zutatenbestand überschreiben
|
|
||||||
public void overwriteStock(String ingredient, int amount) {
|
|
||||||
if (amount < 0) {
|
|
||||||
System.out.println("Ungültige Menge: " + amount);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (stock.containsKey(ingredient)) {
|
|
||||||
stock.put(ingredient, amount);
|
|
||||||
System.out.println(ingredient + " Bestand auf " + amount + " gesetzt.");
|
|
||||||
} else {
|
|
||||||
System.out.println(ingredient + " ist nicht im Lager vorhanden. Hinzufügen mit neuer Menge.");
|
|
||||||
stock.put(ingredient, amount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
class Menu {
|
public class Menu {
|
||||||
public List<Dish> dishes = new ArrayList<>();
|
public List<Dish> dishes = new ArrayList<>();
|
||||||
public List<Dish> availableDishes = 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("Cheeseburger", Map.of("Brot", 1, "Fleisch", 1, "Käse", 1), 5.0));
|
||||||
dishes.add(new Dish("Veggie-Burger", Map.of("Brot", 1, "Salat", 1, "Tomaten", 1)));
|
dishes.add(new Dish("Veggie-Burger", Map.of("Brot", 1, "Salat", 1, "Tomaten", 1), 4.0));
|
||||||
dishes.add(new Dish("Double Meat Burger", Map.of("Brot", 1, "Fleisch", 2)));
|
dishes.add(new Dish("Double Meat Burger", Map.of("Brot", 1, "Fleisch", 2), 6.0));
|
||||||
dishes.add(new Dish("Ramen", Map.of("Soße", 1, "Salat", 1, "Tomaten", 1, "Nudeln", 30)));
|
dishes.add(new Dish("Ramen", Map.of("Soße", 1, "Salat", 1, "Tomaten", 1, "Nudeln", 30), 7.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void displayMenu(Inventory inventory) {
|
public void displayMenu(Inventory inventory) {
|
||||||
System.out.println("Verfügbares Menü:");
|
System.out.println("Verfügbares Menü:");
|
||||||
for (Dish dish : dishes) {
|
for (Dish dish : dishes) {
|
||||||
|
|
|
||||||
|
|
@ -272,4 +272,4 @@ class SystemController {
|
||||||
default -> System.out.println("Ungültige Auswahl.");
|
default -> System.out.println("Ungültige Auswahl.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
**/}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
01,100
|
Tomaten:100
|
||||||
Soße,49999996
|
Salat:260
|
||||||
Ananasdasdas,5000
|
Käse:100
|
||||||
Brot,1503
|
Brot:100
|
||||||
Tomaten,503
|
Soße:100
|
||||||
Käse,715
|
Fleisch:200
|
||||||
Fleisch,93
|
Nudeln:150
|
||||||
Salat,494
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
Dimitry:1234:MANAGER
|
Dimitry:1234:MANAGER
|
||||||
Abbas:1234:MANAGER
|
Abbas:1234:MANAGER
|
||||||
Ananas Kopf:Bananenbieger:KITCHEN
|
Ananas Kopf:Bananenbieger:KITCHEN
|
||||||
|
Arim:1234:MANAGER
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue