Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one category is fixed for every customer like water bottle, salad and another category is according to the list of items that the customer orders like number of biriyani plates, number of dosas etc. Now, write an abstract class fixed Category having the price of the fixed items as data member and an abstract method complimentaryCost(). Write another derived class orderedCategory which will have price of the food items that the customer has ordered as instance variable and one method ordereditemsCost() which will calculate the cost of ordered items. Also implement the abstract method complimentaryCost() in this derived class to find the cost for complementary items. Assume the customer has ordered each food item only once. Write a java code to display the attributes from each of the classes creating proper instances and invoking the methods from another main class customerCost. Assume price of water bottle is 20, salad 80, biriyani 450, dosa 150. Description fixed Category abstract class. fixed Category abstract class ordered Category derived concrete class ordered Category derived concrete class ordered Category derived concrete class customerCost is a public class where main function/method is written Description Variables double bottle_price, salad_price, complimentaryCost() is abstract method complimentaryCost() is abstract method Variable biriyani_price, dosa_price ordered ItemsCost() is a concrete method which will add the cost of the food items Give definition for the abstract method complimentaryCost()which will add the cost of the food items Sample Input Bottle_price=20, Salad_price-80 biriyani_price=450, dosa_price=150 Sample Output cost of order is 600 cost for complementary items is 100

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one category is fixed for every customer like water bottle, salad and another category is according to the list
of items that the customer orders like number of biriyani plates, number of dosas etc.
Now, write an abstract class fixed Category having the price of the fixed items as data member and an abstract method complimentaryCost().
Write another derived class ordered Category which will have price of the food items that the customer has ordered as instance variable and one method ordered itemsCost() which will calculate the cost of
ordered items. Also implement the abstract method complimentaryCost() in this derived class to find the cost for complementary items. Assume the customer has ordered each food item only once.
Write a java code to display the attributes from each of the classes creating proper instances and invoking the methods from another main class customerCost. Assume price of water bottle is 20, salad 80,
biriyani 450, dosa 150.
Description
fixed Category abstract class
fixed Category abstract class
ordered Category derived concrete class
ordered Category derived concrete class
ordered Category derived concrete class
customer Cost is a public class where main
function/method is written
Description
Variables double bottle_price, salad_price,
complimentaryCost() is abstract method
complimentaryCost() is abstract method
Variable biriyani_price, dosa_price
ordered Items Cost() is a concrete method which
will add the cost of the food items
Give definition for the abstract method
complimentaryCost()which will add the cost of the
food items
Sample Input
Bottle_price=20,
Salad_price-80
biriyani_price=450,
dosa_price=150
Sample Output
cost of ordered items is 600
cost for complementary items is 100
Transcribed Image Text:Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one category is fixed for every customer like water bottle, salad and another category is according to the list of items that the customer orders like number of biriyani plates, number of dosas etc. Now, write an abstract class fixed Category having the price of the fixed items as data member and an abstract method complimentaryCost(). Write another derived class ordered Category which will have price of the food items that the customer has ordered as instance variable and one method ordered itemsCost() which will calculate the cost of ordered items. Also implement the abstract method complimentaryCost() in this derived class to find the cost for complementary items. Assume the customer has ordered each food item only once. Write a java code to display the attributes from each of the classes creating proper instances and invoking the methods from another main class customerCost. Assume price of water bottle is 20, salad 80, biriyani 450, dosa 150. Description fixed Category abstract class fixed Category abstract class ordered Category derived concrete class ordered Category derived concrete class ordered Category derived concrete class customer Cost is a public class where main function/method is written Description Variables double bottle_price, salad_price, complimentaryCost() is abstract method complimentaryCost() is abstract method Variable biriyani_price, dosa_price ordered Items Cost() is a concrete method which will add the cost of the food items Give definition for the abstract method complimentaryCost()which will add the cost of the food items Sample Input Bottle_price=20, Salad_price-80 biriyani_price=450, dosa_price=150 Sample Output cost of ordered items is 600 cost for complementary items is 100
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT