Question
Java Help _________________________________________ Implement the ULM diagram above. Separate files for each class. Each class with a constructor and toString() method. toString() will return a
Java Help
_________________________________________
Implement the ULM diagram above. Separate files for each class. Each class with a constructor and toString() method. toString() will return a String with the labeled variables of each member variables.
The constructor will accept the name as an argument (as many arguments). Use super() to call the base class constructor and pass up the name.
From each of the 3 subclasses above derive 2 classes of your own. You can choose to add more member variables or just use the inherited from the parent classes. Provide each class with a constructor that sets of all the member variables, both local and inherited. Use super() to pass the name up the base class constructor.
In main() create an array of 6 items. Assign each element an object from each of your classes. Use a for loop to call toString() on all 6 elements. Display the Strings as they are returned.
Example
Class chocolateCake extends Dessert {
ChocolateCake () {
super(Chocolate Cake);
price = 4.99f;
}
}
Item name description price calories String String float int Item(String name) toString Beverage Entre Dessert sugarFree bool hot alcoholic oz Sizes size bool bool float enum Sizes vegetarian Category category bool enum Catagory Entree(String name) toString Dessert(String name) toString Beverage(String name) toStringStep 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