Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create an abstract class called Sandwiches that has a sandwich name, type, price and number of ordered sandwiches. It also has respective auto-implemented properties for
- Create an abstract class called "Sandwiches" that has a sandwich name, type, price and number of ordered sandwiches. It also has respective auto-implemented properties for all fields apart from the price, where its property checks whether the assigned value is positive or not. If a negative number is assigned as a price, the program should display a warning message. The class also contains a method called "GetSandwichInfo" that displays the name and type of the sandwich. Moreover, the class implements an interface called "IBuyable" that has a method called "CalculatePrice" and accept two parameters; a sandwich price and number of sandwiches.
- Create a child class called "SignatureSandwiches" that has a constructor that requires passing all fields (name, type, price and number of sandwiches ordered), and an implementation of the abstract method it inherits.
- In the Main method, instantiate two objects from the "SignatureSandwiches" class and invokethe "GetSandwichInfo" and "CalculatePrice" methods by passing the appropriate list of parameters.
Sample output :
Sandwich ordered is Meat Based and its name is Cheese Burger
Total Price is 13.50
Step 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