Question
In C# Implement a set of classes for dining out that will demonstrate polymorphism. An abstract Restaurantclass will have abstract methods such as GetMenu, GetBill,
In C#
Implement a set of classes for dining out that will demonstrate polymorphism. An abstract Restaurantclass will have abstract methods such as GetMenu, GetBill, OrderFood, PayBill, and so on. Implement an EatOut method by calling the abstract methods in the order they would occur in a typical restaurant scenario. Implement FastFood, CoffeeShop, and Fancy derived classes of Restaurant which implement all the abstract methods, using stubs to print messages describing what would happen in that type of restaurant. For example, the OrderFood method in the FastFood class might describe talking to a machine from a car window in a drive-through line, and the OrderFood method in the Fancy class might call a method to order wine to go with the meal. To demonstrate the polymorphism, declare several restaurant objects that refer to the various derived classes. Calling the EatOut method for each restaurant will show that each behaves in its own way, appropriate to that type of restaurant. A derived class may override the EatOut method if the order of method calls defined in the EatOut method in the Restaurant class is not appropriate for that derived class.
Your main calling function should look something like this:
public static void DoEx10_13()
{
Restaurant fast = new FastFood();
fast.EatOut();
Restaurant coffee = new CoffeeShop();
coffee.EatOut();
Restaurant fancy = new FancyRestaurant();
fancy.EatOut();
}
Your output should look something like this:
The fast food resant Look at the menu above you I'd like a taco and a cola That will be $2.50 Customer hands the cashier a five-dollar bill and gets change This is good with hot sauce The coffee shop Here are your menus I'd like the fish special with rice This is good with tartar sauce May I have the check, please? Customer hands the cashier a twenty-dollar bill and gets change This is the fancy restaurant Here are your menus I'd like the lobster Newburg and a glass of your best Chardonnay The wine has a fine bouquet Waiter places a folder with the check enclosed on the table Customer places a credit card inside the folder The fast food resant Look at the menu above you I'd like a taco and a cola That will be $2.50 Customer hands the cashier a five-dollar bill and gets change This is good with hot sauce The coffee shop Here are your menus I'd like the fish special with rice This is good with tartar sauce May I have the check, please? Customer hands the cashier a twenty-dollar bill and gets change This is the fancy restaurant Here are your menus I'd like the lobster Newburg and a glass of your best Chardonnay The wine has a fine bouquet Waiter places a folder with the check enclosed on the table Customer places a credit card inside the folderStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started