Knowee
Questions
Features
Study Tools

you are tasked with developing a canteen management system for a university campus. The canteen offers three main categories of items: snacks, beverages, and meals. Each category has specific attributes. Using classes, objects, function overloading, constructors, and access specifiers, create a system that allows the user to add and display details of items available in the canteen, including their quantity.Instructions:Implement three classes: Snack, Beverage, and Meal.Each class should have private attributes for storing item details, including name, price, quantity, expiration date, and additional attributes specific to each category.Overload constructors for each class to initialize objects with different sets of parameters.Create functions to add and display details of items in the canteen.Sample InputEnter Snack Details:Name: CookiesPrice: 1.5Quantity: 100Expiration Date: 2024-05-31Enter Beverage Details:Name: LemonadePrice: 1.25Quantity: 75Expiration Date: 2024-06-15Volume: 16 ozType: Soft DrinkEnter Meal Details:Name: SpaghettiPrice: 10.75Quantity: 50Expiration Date: 2024-05-20Ingredients: Pasta, Tomato Sauce, MeatballsCooking Time: 45 minutesType: DinnerSample OutputCanteen Items Details:Snack Details:Name: CookiesPrice: $1.5Quantity available: 100Expiration Date: 2024-05-31Beverage Details:Name: LemonadePrice: $1.25Quantity available: 75Expiration Date: 2024-06-15Volume: 16 ozType: Soft DrinkMeal Details:Name: SpaghettiPrice: $10.75Quantity available: 50Expiration Date: 2024-05-20Ingredients: Pasta, Tomato Sauce, MeatballsCooking Time: 45 minutesType: Dinner

Question

you are tasked with developing a canteen management system for a university campus. The canteen offers three main categories of items: snacks, beverages, and meals. Each category has specific attributes. Using classes, objects, function overloading, constructors, and access specifiers, create a system that allows the user to add and display details of items available in the canteen, including their quantity.Instructions:Implement three classes: Snack, Beverage, and Meal.Each class should have private attributes for storing item details, including name, price, quantity, expiration date, and additional attributes specific to each category.Overload constructors for each class to initialize objects with different sets of parameters.Create functions to add and display details of items in the canteen.Sample InputEnter Snack Details:Name: CookiesPrice: 1.5Quantity: 100Expiration Date: 2024-05-31Enter Beverage Details:Name: LemonadePrice: 1.25Quantity: 75Expiration Date: 2024-06-15Volume: 16 ozType: Soft DrinkEnter Meal Details:Name: SpaghettiPrice: 10.75Quantity: 50Expiration Date: 2024-05-20Ingredients: Pasta, Tomato Sauce, MeatballsCooking Time: 45 minutesType: DinnerSample OutputCanteen Items Details:Snack Details:Name: CookiesPrice: 1.5Quantityavailable:100ExpirationDate:20240531BeverageDetails:Name:LemonadePrice:1.5Quantity available: 100Expiration Date: 2024-05-31Beverage Details:Name: LemonadePrice: 1.25Quantity available: 75Expiration Date: 2024-06-15Volume: 16 ozType: Soft DrinkMeal Details:Name: SpaghettiPrice: $10.75Quantity available: 50Expiration Date: 2024-05-20Ingredients: Pasta, Tomato Sauce, MeatballsCooking Time: 45 minutesType: Dinner

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple implementation in Python:

class Item:
    def __init__(self, name, price, quantity, expiration_date):
        self.__name = name
        self.__price = price
        self.__quantity = quantity
        self.__expiration_date = expiration_date

    def display(self):
        print(f"Name: {self.__name}\nPrice: ${self.__price}\nQuantity available: {self.__quantity}\nExpiration Date: {self.__expiration_date}")

class Snack(Item):
    pass

class Beverage(Item):
    def __init__(self, name, price, quantity, expiration_date, volume, type):
        super().__init__(name, price, quantity, expiration_date)
        self.__volume = volume
        self.__type = type

    def display(self):
        super().display()
        print(f"Volume: {self.__volume}\nType: {self.__type}")

class Meal(Item):
    def __init__(self, name, price, quantity, expiration_date, ingredients, cooking_time, type):
        super().__init__(name, price, quantity, expiration_date)
        self.__ingredients = ingredients
        self.__cooking_time = cooking_time
        self.__type = type

    def display(self):
        super().display()
        print(f"Ingredients: {self.__ingredients}\nCooking Time: {self.__cooking_time} minutes\nType: {self.__type}")

# Sample Input
snack = Snack("Cookies", 1.5, 100, "2024-05-31")
beverage = Beverage("Lemonade", 1.25, 75, "2024-06-15", "16 oz", "Soft Drink")
meal = Meal("Spaghetti", 10.75, 50, "2024-05-20", "Pasta, Tomato Sauce, Meatballs", 45, "Dinner")

# Sample Output
print("Canteen Items Details:")
print("Snack Details:")
snack.display()
print("\nBeverage Details:")
beverage.display()
print("\nMeal Details:")
meal.display()

This code creates a base class Item with private attributes for name, price, quantity, and expiration date. It also has a display method to print these details. The Snack, Beverage, and Meal classes inherit from Item and add their own specific attributes. The display method is overridden in Beverage and Meal to include these additional details. The sample input and output show how to create objects of these classes and display their details.

This problem has been solved

Similar Questions

Problem Statement:Your university wants you to create a management system that will store employee data in the following hierarchy. Create the necessary classes that represent the following diagram: The attributes for each of the classes are provided in the diagram for your reference.In addition to the Staff, Management, and the Teacher classes, you need to create the Education class which should be associated only with the Teacher and the Management.You have to create a menu based application to store and display the data.The input options shall be 1 for Teacher, 2 for Management, and 3 for Admin.For each of these options you display the type of data being provided as input and request the user to enter the relevant information. For qualification, you shall provide them with options from 1-4 and once all the data has been provided, you shall then display the given information in a formatted output.Once the data has been displayed, you should then print "Staff being deleted..." in the Staff class's destructor.Please refer to the input and output section for more details.Input format :The input consists of an integer choice, followed by data related to a specific employee type (Teacher, Management, or Admin) based on the given choice.For Teacher:choice = 1Employee code (string)Employee name (string)Educational qualification (integer): (1: - Undergraduate, 2 - Graduate, 3 - Masters Degree, 4 - PhD)Subject (string)For Management:choice = 2Employee code (string)Employee name (string)Educational qualification (integer): (1: - Undergraduate, 2 - Graduate, 3 - Masters Degree, 4 - PhD)Management Grade (float)For Admin:choice = 3Employee code (string)Employee name (string)Department (string)Output format :The output displays the user information based on the user input, along with the "Staff being deleted..." message from the destructor.A new line space is given after the last line of the output.Refer to the sample output for the formatting specifications.Code constraints :The educational qualification should only be within the given range of 1 to 4The choice will be an integer between 1 and 3 (inclusive).Employee code, employee name, subject, and department will be strings with a maximum length of 20 characters.Educational qualification will be an integer (1, 2, 3, or 4).Management Grade should be an integer.Sample test cases :Input 1 :1ABC3343HarryPotter2WizardryOutput 1 :TEACHER The given information:Employee code: ABC3343Employee name: HarryPotterEducational Qualification: GraduateSubject: WizardryStaff being deleted...Staff being deleted...Staff being deleted...Input 2 :2KLD34RonWeasley34Output 2 :MANAGEMENT The given information:Employee code: KLD34Employee name: RonWeasleyEducational Qualification: Masters DegreeManagement Grade: 4Staff being deleted...Staff being deleted...Staff being deleted...Input 3 :3CMS34343HermioneCompsciOutput 3 :ADMIN The given information:Employee code: CMS34343Employee name: HermioneDepartment: CompsciStaff being deleted...Staff being deleted...Staff being deleted...Input 4 :4Output 4 :Invalid choiceStaff being deleted...Staff being deleted...Staff being deleted...Input 5 :2KLD34RonWeasley6532Output 5 :MANAGEMENTInvalid Educational Qualification. Try one more time.Invalid Educational Qualification. Try one more time. The given information:Employee code: KLD34Employee name: RonWeasleyEducational Qualification: Masters DegreeManagement Grade: 2Staff being deleted...Staff being deleted...Staff being deleted...Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.

Develop a java application to handle the menu details of Sandy Food Inc. Company. Your application will handle the Sandwich product details. There are three types of Sandwiches under Sandwich class, they are Sweet, Sour, Hot. Each has two sub types of Sandwiches like small and medium. The members are ProductName – String (Sweet Small / Sweet Medium / Sour Small…) Price – Integer ProductCode - Integer GetOrder() - method to get the Product code and number of quantities. DisplayPrice() - method to display the Product name, number of quantities and cost. Your application should calculate the cost of the ordered product based on the quantity and price. Single order will not have more than one type of product. The price range of different products with the product code and product name are tabulated below. S.No Product name Product Code Price 1 Sweet Small 101 100/- 2 Sweet Medium 102 150/- 3 Sour Small 103 150/- 4 Sour Medium 104 200/- 5 Hot Small 105 200/- 6 Hot Medium 106 250/- Ensure that the bill value is calculated only on the respective class. The inputs are the product code and the quantity of the product. The expected output is the product name, quantity and price. If the entry is wrong product code, then handle with exception and display the message as “Invalid”.

Objective: The objective of this activity is to implement a basic inventory management system using Java programming concepts such as user-defined methods, scanner, arrays, loops, and conditions.Task Overview:1. Create a new Java class named `InventorySystem`.2. Declare the following static variables inside the `InventorySystem` class:   - `MAX_ITEMS`: an integer constant to define the maximum number of items in the inventory (set it to 10).   - `items`: a string array to store the names of the items in the inventory (initialize it with the size of `MAX_ITEMS`).   - `quantities`: an integer array to store the quantities of the items in the inventory (initialize it with the size of `MAX_ITEMS`).3. Implement the `main` method inside the `InventorySystem` class:   - Create a `Scanner` object named `scanner` to read user input from the console.   - Use a `while` loop to keep the program running until the user chooses to exit.   - Inside the loop, display a menu of options to the user:     1. Add item to inventory     2. Sell item from inventory     3. Display inventory     4. Exit   - Use a `switch` statement to execute the corresponding action based on the user's choice (1, 2, 3, or 4).   - If the user selects option 1, call the `addItem` method.   - If the user selects option 2, call the `sellItem` method.   - If the user selects option 3, call the `displayInventory` method.   - If the user selects option 4, exit the program.Sample Output 4. Implement the `displayInventory` method:   - Iterate through the `items` and `quantities` arrays and display the name and quantity of each item in the inventory.Sample OutputNote: For other displayInventory functions, check the sample output in the addItem and in the sellItem methods. 5. Implement the `addItem` method:   - Prompt the user to enter the name of the item to be added.   - Check if the item already exists in the inventory by searching for its name in the `items` array.   - If the item does not exist, add it to the list. Automatically it will have value of 1.   - If the item already exists, prompt the user to enter the quantity to be added.   - Update the quantity of the existing item in the `quantities` array.Sample Output6. Implement the `sellItem` method:   - Prompt the user to enter the name of the item to be sold.   - Check if the item exists in the inventory by searching for its name in the `items` array.   - If the item does not exist or if its quantity is 0, display an error message.   - If the item exists and its quantity is greater than 0, prompt the user to enter the quantity to be sold.   - Update the quantity of the sold item in the `quantities` array.Sample Output7. Compile and run the `InventorySystem` class to test the inventory management system.8. Test the system by adding items to the inventory, selling items, and displaying the current inventory.9. When exit is chosen, the program will terminate

Create a theme for the dinner and an appropriate Service Style Design a Dinner menu for the Awards ceremony Ensure that Two (2) different ethnic meals are included. Ensure a Vegetarian option is included. The menu must meet the recommended food intake according to the different food groups. Prepare a costing for the Menu to be sent to the Awards Dinner Committee. Prepare a Recipe card for one (1) protein and one (1) carbohydrate item on the menu. Select and justify the appropriate food service types to be used for the function. Design the Organizational Charts to be used for the function Create a work schedule/ flow chart to be used for the function. Create an appropriate budget for the event.

Imagine you're asked with creating a simple Java program for managing a LMS. Your program should have a Book class representing books in the library. Each book has attributes such as title, author, ISBN, and yearPublished.REQUIREMENTS::Define a Book class with private instance variables for title, author, ISBN, and yearPublished.Implement a constructor that initializes all these instance variables.Provide a default constructor that sets default values for title, author, ISBN, and yearPublished in case no values are provided during object creation.Implement getdata and displaydata methods for all instance variables.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.