Question

Design a restaurant class to help manage multiple restaurants and their menus equiremen The class contains: 1) A static int v

program is C#

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Create a C# console application with the name ManageRestaurants. Rename Program.cs as Restaurant.cs. Add the below code

Restaurant.cs

using System;

namespace ManageRestaurants
{
    class Restaurant
    {
        //class variables
        private static int storeCounter = 1;
        private string[] Menu;
        private int StoreID;
        private Boolean isOpen;

        //no-argument constructor
        public Restaurant()
        {
            //set the store id
            StoreID = storeCounter;
            // increment the storeCounter
            storeCounter++;
            //set isOpen to true
            isOpen = true;
            //set the menu size to 3
            Menu = new string[3];
        }

        //constructor with paramters
        public Restaurant(int iParam, Boolean bParam)
        {
            //set the store id
            StoreID = storeCounter;
            // increment the storeCounter
            storeCounter++;
            //set isOpen
            isOpen = bParam;
            //set the menu size
            Menu = new string[iParam];
        }

        //method that sets the Menu
        public void setMenu(String[] menuItems)
        {
            //set the menu items
            Menu = menuItems;
        }

        /* Use this method if you want to take menu items from the user
         * public void setMenu()
        {
            for(int i = 0; i < Menu.Length; i++)
            {
                Console.Write("Enter Menu Item #" + i + ": ");
                Menu[i] = Console.ReadLine();
            }
         }*/

        //method that sets first three items of the menu
        public void setMenuEasy()
        {
            Menu[0] = "Hamburger";
            Menu[1] = "Hot dog";
            Menu[2] = "Pizza";
        }

        //method that prints the restaurant details
        public void restaurantDetails()
        {
            //print the store id
            Console.WriteLine("StoreID: " + StoreID);
            //print the menu items
            Console.WriteLine("Menu: ");
            for (int i = 0; i < Menu.Length; i++)
            {
                Console.WriteLine((i + 1) + ". " + Menu[i]);
            }
            //print whether the restaurant is open or not
            if (isOpen)
                Console.WriteLine("The Restaurant is Open.");
            else
                Console.WriteLine("The Restaurant is Closed.");
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            // create 3 new Restaurants
            // one with default constructor
            Restaurant r1 = new Restaurant();
            // second with open and menu size 4
            Restaurant r2 = new Restaurant(4, true);
            // third with closed and menu size 3
            Restaurant r3 = new Restaurant(3, false);
            // call setMenuEasy for 1st and 3rd restaurant
            r1.setMenuEasy();
            r3.setMenuEasy();
            // call setMenu for 2nd restaurant
            String[] items = { "Pizza", "Burger", "Pasta" };
            r2.setMenu(items);
            //print the restaurant details of all the restaurants
            r1.restaurantDetails();
            r2.restaurantDetails();
            r3.restaurantDetails();
            Console.ReadLine();
        }
    }
}

Output:

file:///E:/DotNet/ManageRestaurants/ManageRestaurants/bin/Debug/IVManagekestaurants StoreID: 1 Menu 1. Hamburger 2. Hot dog 3

Program Screenshot:

Restaurant.cs X ManageRestaurants MaageRestaurants.Restaurant using System; namespace ManageRestaurants 4 8 references classRestaurant.cs X ageRestaurants.Restaurant Icy ManageRestaurants //constructor with paramters 2 references public Restaurant (Restaurant.cs X Main(stringl] args) ManageRestaurants ManageRestaurants.Restaurant /* Use this method if you want to take menRestaurant.cs X Main(string ManageRestaurants MaageRestaurants.Restaurant //method that prints the restaurant details 3 refervi d nagenestaurarlls.heSLdurdnt 82 0 references static void Main (string[] args) 83 84 85 86 87 // create 3 new Restaurants

Let me know if you have any concerns with the above solution.

Add a comment
Know the answer?
Add Answer to:
Design a restaurant class to help manage multiple restaurants and their menus equiremen The class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program to help some local coffee shops manage their menus Requirements The class contai...

    program is C# Create a program to help some local coffee shops manage their menus Requirements The class contains: 1) A method called defaultMenu that returns a String list and has no parameters. When called, the method returns a string list containing the following elements: {"Coffee", "Americano", Cappuccino" A method called custom Menu that returns a String list and has an int parameter. When called, the method will create a new string list, then ask the user for items to...

  • Create a class called Restaurant that is the base class for all restaurants. It should have...

    Create a class called Restaurant that is the base class for all restaurants. It should have attributes for the restaurant's name{protected) and seats (private attribute that represents the number of seats inside the restaurant). Use the UML below to create the methods. Note, the toString prints the name and the number of seats. Derive a class Fastfood from Restaurant This class has one attribute - String slogan (the slogan that the restaurants uses when advertising - e.g., "Best Burgers Ever!")....

  • Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to...

    Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the annualInterestRate to a new value....

  • C++ Create a User class, with a separate interface (User.h) and implementation (User.cpp), comprised of the...

    C++ Create a User class, with a separate interface (User.h) and implementation (User.cpp), comprised of the following attributes: Data members (private): string: username int array: ratings Number of elements should be size int: numRatings Number of books in the database Int: size The capacity of the ratings array (50). Constant Member functions (public): Default constructor Sets username to an empty string, numRatings to 0, size to 50, and all the elements of ratings array to the value 0 Parameterized constructor...

  • This is the Java Object-oriend project. Please show the detail code and comment for each class....

    This is the Java Object-oriend project. Please show the detail code and comment for each class. Thank you Create a class Door with the following UML specification: +---------------------+ | Door | +---------------------+ | - isOpen: boolean | +---------------------+ | + Door() | | + isOpen(): boolean | | + open(): void | | + close(): void | | + testDoor(): void | +---------------------+ where isOpen is an instance variable indicating whether the door is currently open or not. The default...

  • Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp....

    Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp. Also uses Super in the TextBook Class section. Problem 1 (10 points) Вook The left side diagram is a UML diagram for Book class. - title: String The class has two attributes, title and price, and get/set methods for the two attributes. - price: double Вook) Book(String, double) getTitle(): String setTitle(String): void + getPrice() double setPrice(double): void toString() String + The first constructor doesn't...

  • Java Program 1. Write a class that reads in a group of test scores (positive integers...

    Java Program 1. Write a class that reads in a group of test scores (positive integers from 1 to 100) from the keyboard. The main method of the class calls a few other methods to calculate the average of all the scores as well as the highest and lowest score. The number of scores is undetermined but there will be no more than 50. A negative value is used to end the input loop. import java.util.Scanner; public class GradeStat {...

  • Application should be in C# programming language Create a class called SavingsAccount.  ...

    Application should be in C# programming language Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the...

  • Write a class called Book. Here are the relevant attributes: title author yearPublished            bookPriceInCAD Provide...

    Write a class called Book. Here are the relevant attributes: title author yearPublished            bookPriceInCAD Provide a constructor that takes parameters to initialize all the instance variables. The constructor calls the mutator (set) methods to initialize the instance variables. Provide an accessor (get) and mutator (set) for each instance variable. The mutators all validate their parameters appropriately and use them only if valid. If the passed parameter was invalid an IllegalArgumentException will be thrown with a proper error message A...

  • Using Java programming language, build a class called IntegerSet. Instructions - Create class IntegerSet An IntegerSet...

    Using Java programming language, build a class called IntegerSet. Instructions - Create class IntegerSet An IntegerSet object holds integers in the range 0-100 Represented by an array of booleans, such that array element a[i] is set to true if integer i is in the set, and false otherwise Create these constructors and methods for the class IntegerSet() public IntegerSet union(IntegerSet iSet) public IntegerSet intersection(IntegerSet iSet) public IntegerSet insertElement(int data) public IntegerSet deleteElement(int data) public boolean isEqualTo(IntegerSet iSet) public String toString()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT