Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this program we are going to utilize multiple classes to demonstrate inheritance and polymorphism. In this homework, you will: Create and use a common

image text in transcribedimage text in transcribed

In this program we are going to utilize multiple classes to demonstrate inheritance and polymorphism. In this homework, you will: Create and use a common base (super or parent) class Create and instantiate 4 subclasses (child classes) that inherit from the base class Maintain a collection (list) of all the related classes and demonstrate polymorphism and method overriding by calling methods on the collection. Problem Statement: You are creating a list of menu items for a new restaurant. All menu items have a name, a price and a category. The various categories are Entree, Appetizer, Side, and Dessert. Entre menu items also have a number of sides associated with them. Appetizer menu items include a number of individual items (for example, there might be 6 potato skins as part of an order of potato skins) Side menu items have a boolean attributes that is true when they are a premium side and false when they are not. (Premium sides are not included with Entre and cost $1 more than non premium) Dessert menu items have a boolean attributes that indicate whether or not they are frozen. Frozen desserts are not offered on to-go menu. Create the four classes above with Entre, Appetizer, Side, and Dessert inheriting from parent class Menultem. Create main method (preferably in its own class). The main menu will contain an ArrayList that holds Menultem objects. Manually hard code (this means create the object and place predetermined values) one each of Entre, Appetizer, Side and Dessert objects. Add them to the ArrayList Create a user dialog using Scanner and System.out.println that prompts user to enter one (1) additional Entre and one (1) additional Dessert. When the additions are done, print the ArrayList with each Menultem on its own line or lines in a readable menu format. All attributes for each of the four child classes should be printed in a user friendly manner. The easiest way to do this is to make sure each child class has an overridden toString() method that prints the info in the format of your menu. Do NOT use the default toString() format for this if you want readability points. Note- you do not need the accent on the second e in Entre to be correct. Word keeps adding it-Java will not add it easily. Example outputs (your menu items may differ in name and price-make it up but be realistic): Entre: Salmon with 2 sides $26.00 Appetizer: Potato Skins 10 items $7.50 Side: Rice $3.00 unless included with Entre Dessert: Ice Cream - Frozen $4.50 Entre: Lobster with 2 sides $40.00 Dessert: Chocolate Cake $6.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

in python nothing seems to work

Answered: 1 week ago