Restaurant Management System


Key Features and Requirements:

Sequnece Diagram
cache
Class Design:

The following are the main components of the system, along with their functionality:

1. Menu Management
        // Class to represent the menu
        class Menu {
            private Map items;
    
            public Menu() {
                items = new HashMap<>();
            }
    
            public void addItem(String name, double price) {
                items.put(name, price);
            }
    
            public Map viewMenu() {
                return items;
            }
        }
    
2. Inventory Management
        // Class to manage restaurant inventory
        class Inventory {
            private Map ingredients;
    
            public Inventory() {
                ingredients = new HashMap<>();
            }
    
            public void updateInventory(String ingredient, int quantity) {
                ingredients.put(ingredient, quantity);
            }
    
            public boolean checkAvailability(String ingredient, int requiredQuantity) {
                return ingredients.getOrDefault(ingredient, 0) >= requiredQuantity;
            }
        }
    
3. Order Management
        // Class to manage orders
        class Order {
            private List items;
            private double totalAmount;
    
            public Order() {
                items = new ArrayList<>();
                totalAmount = 0;
            }
    
            public void addItem(String item, double price) {
                items.add(item);
                totalAmount += price;
            }
    
            public double getTotalAmount() {
                return totalAmount;
            }
    
            public List getItems() {
                return items;
            }
        }
    
4. Payment Processing
        // Enum for payment methods
        enum PaymentMethod {
            CASH, CREDIT_CARD, MOBILE
        }
    
        // Class to handle payment processing
        class Payment {
            public boolean processPayment(double amount, PaymentMethod method) {
                System.out.println("Processing payment of " + amount + " using " + method);
                // Simulate payment processing
                return true;
            }
        }
    
5. Reservation Management
        // Class to manage reservations
        class Reservation {
            private Map reservations;
    
            public Reservation() {
                reservations = new HashMap<>();
            }
    
            public boolean makeReservation(String customerName, String time) {
                if (reservations.containsKey(time)) {
                    return false; // Time slot already booked
                }
                reservations.put(time, customerName);
                return true;
            }
        }
    
6. Staff Management
        // Class to manage staff
        class Staff {
            private String name;
            private String role;
    
            public Staff(String name, String role) {
                this.name = name;
                this.role = role;
            }
    
            public String getName() {
                return name;
            }
    
            public String getRole() {
                return role;
            }
        }
    
        // Class to manage staff schedules
        class StaffSchedule {
            private Map schedule;
    
            public StaffSchedule() {
                schedule = new HashMap<>();
            }
    
            public void setSchedule(String staffName, String scheduleTime) {
                schedule.put(staffName, scheduleTime);
            }
    
            public String getSchedule(String staffName) {
                return schedule.get(staffName);
            }
        }
    
7. Report and Analytics
        // Class for generating sales reports
        class Report {
            public void generateSalesReport(List orders) {
                double totalSales = orders.stream().mapToDouble(Order::getTotalAmount).sum();
                System.out.println("Total Sales: $" + totalSales);
            }
    
            public void generateInventoryReport(Inventory inventory) {
                System.out.println("Inventory Report: " + inventory);
            }
        }
    
8. Main Class - Simulating Interaction
        public class RestaurantManagementSystem {
    
            public static void main(String[] args) {
                // Create instances of required classes
                Menu menu = new Menu();
                Inventory inventory = new Inventory();
                Order order = new Order();
                Payment payment = new Payment();
                Reservation reservation = new Reservation();
                StaffSchedule staffSchedule = new StaffSchedule();
                Report report = new Report();
    
                // Add items to the menu
                menu.addItem("Pizza", 10.00);
                menu.addItem("Pasta", 8.50);
                menu.addItem("Salad", 5.00);
    
                // Manage inventory
                inventory.updateInventory("Tomato", 100);
                inventory.updateInventory("Cheese", 50);
    
                // Customer places an order
                order.addItem("Pizza", 10.00);
                order.addItem("Pasta", 8.50);
    
                // Check inventory before confirming order
                if (inventory.checkAvailability("Tomato", 2) && inventory.checkAvailability("Cheese", 1)) {
                    System.out.println("Order placed: " + order.getItems());
                    System.out.println("Total Amount: $" + order.getTotalAmount());
                } else {
                    System.out.println("Insufficient ingredients for the order.");
                }
    
                // Process payment
                payment.processPayment(order.getTotalAmount(), PaymentMethod.CREDIT_CARD);
    
                // Make a reservation
                if (reservation.makeReservation("John Doe", "7:00 PM")) {
                    System.out.println("Reservation confirmed for John Doe at 7:00 PM.");
                } else {
                    System.out.println("Sorry, the time slot is already booked.");
                }
    
                // Manage staff schedule
                staffSchedule.setSchedule("Jane Doe", "9:00 AM - 5:00 PM");
    
                // Generate reports
                report.generateSalesReport(Arrays.asList(order));
                report.generateInventoryReport(inventory);
            }
        }