Restaurant.java

mail@pastecode.io avatar
unknown
plain_text
7 months ago
3.0 kB
11
Indexable
Never
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Restaurant
{
	private static ArrayList<MenuItem> Appetizers = new ArrayList<>();
	private static ArrayList<MenuItem> MainCourse = new ArrayList<>();
	private static ArrayList<MenuItem> Desserts = new ArrayList<>();
	private static ArrayList<MenuItem> Beverages = new ArrayList<>();
	private static HashMap<String, ArrayList<MenuItem>> menuCategories = new HashMap<>();
	
public ArrayList<MenuItem> getAppetizers()
{
	return Appetizers;
}

public ArrayList<MenuItem> getMainCourse()
{
	return MainCourse;
}

public ArrayList<MenuItem> getDesserts()
{
	return Desserts;
}

public ArrayList<MenuItem> getBeverages()
{
	return Beverages;
}

public void listMenu()
{
	Appetizers.add(new Appetizer("Breadsticks with Marinara Sauce", 7.00));
	Appetizers.add(new Appetizer("Garlic Cheese Knots", 9.00));
	Appetizers.add(new Appetizer("Ceasar Salad", 5.00));
	
	MainCourse.add(new MainCourse("Pepperoni Pizza", 13.00));
	MainCourse.add(new MainCourse("Cheese Pizza", 12.00));
	MainCourse.add(new MainCourse("Supreme Pizza", 14.00));
	
	Desserts.add(new Dessert("Apple Pie", 7.00));
	Desserts.add(new Dessert("S'mores Pizza", 11.00));
	Desserts.add(new Dessert("Churros", 6.50));
	
	Beverages.add(new Beverage("Fountain Drink", 2.50));
	Beverages.add(new Beverage("House Special Cocktail", 5.00));
	Beverages.add(new Beverage("2 Liter Soda", 3.00));
	
	menuCategories.put("Appetizers", Appetizers);
	menuCategories.put("MainCourse", MainCourse);
	menuCategories.put("Desserts", Desserts);
	menuCategories.put("Beverages", Beverages);
}

public Restaurant() {
    ArrayList<MenuItem> Appetizers;
    ArrayList<MenuItem> MainCourse;
    ArrayList<MenuItem> Desserts;
    ArrayList<MenuItem> Beverages;
    HashMap<String, ArrayList<MenuItem>> menuCategories;
    listMenu();
}

public void displayMenuOptions()
{
	System.out.println("Select Menu Category to view.");
	System.out.println("1. Appetizers");
	System.out.println("2. Main Course");
	System.out.println("3. Desserts");
	System.out.println("4. Beverages");
	
	Scanner scnr = new Scanner(System.in);
	
	int selection = scnr.nextInt();
	
	switch(selection)
	{
	case 1:	
		displayOptions("Appetizers", getAppetizers());
		break;
	case 2:
		displayOptions("MainCourse", getMainCourse());
		break;
	case 3: 
		displayOptions("Desserts", getDesserts());
		break;
	case 4:
		displayOptions("Beverages", getBeverages());
		break;
	default:
		System.out.println("Invalid choice. Returning to main menu.");
		
	}
}

private void displayOptions(String category, ArrayList<MenuItem> items)
{
	System.out.println(category + ":");
    displayMenuItems(items);
}

private void displayMenuItems(ArrayList<MenuItem> items) {
    for (MenuItem item : items) {
        System.out.println(item);
    }
}

public double calculateBill(ArrayList<MenuItem> items)
{
	 double total = 0.0;
     for (MenuItem item : items) 
     {
         total += item.getPrice();
     }
     return total * 1.06;
}


}

Leave a Comment