Computers and Technology
Computers and Technology, 08.07.2019 16:10, nick607

The abstract class dessert contains data members name and cost. it also defines public methods string which returns the name of the dessert, and public method int implement both of these methods and the standard methods tostring() (return the name and cost of the dessert concatenated in a string) and equals(object) in the following subclasses: • the cake class is derived from the dessert class. a cake object has a number of layers (int). the price of a cake is $15 + $2 per layer. for example, a 3-layer cake costs $21. the number of layers is passed as the parameter to the cake constructor. • the cookiepack class is derived from the dessert class. a cookiepack object has a number (int) indicating how many cookies are in the pack and a price per cookie in dollars (int) which are used to determine its cost. for example, a 5-cookie pack at $2 per cookie = $10. the name/type of the cookies (e. g., chocolate chip cookies) and these two integers are passed in as the parameters to the cookiepack constructor. • the icecream class is derived from the dessert class. an icecream object simply has a cost in dollars (int). the starting value of this cost is passed as the parameter to the icecream constructor. • the sundae class is derived from the icecream class. the cost of a sundae is the cost of the icecream plus the cost of the topping in dollars (int). the starting value of the topping’s cost is passed as a parameter to the sundae constructor.

answer
Answers: 2

Similar questions

Do you know the correct answer?
The abstract class dessert contains data members name and cost. it also defines public methods strin...

Questions in other subjects: