4. 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 lis 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 xed Category abstract class rderedCategory derived concrete class dered Category derived concrete class Description Variables double bottle_price, salad_price, complimentaryCost() is abstract method complimentaryCost() is abstract method Variable biriyani_price, dosa_price orderedItemsCost() is a concrete method 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
4. 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 lis 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 xed Category abstract class rderedCategory derived concrete class dered Category derived concrete class Description Variables double bottle_price, salad_price, complimentaryCost() is abstract method complimentaryCost() is abstract method Variable biriyani_price, dosa_price orderedItemsCost() is a concrete method 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
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 18RQ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT