Question: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA.
- Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
- Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
- In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.
The Meal class and its subclass DeluxeMeal are used to represent meals at a restaurant.
All Meal objects have the following attributes and methods.
- A String variable representing the name of the entree included in the meal
- A double variable representing the cost, in dollars, of the meal
- A toString method that indicates information about the meal
The following table shows the intended behavior of the Meal class.
| Statement | Result |
| Meal burger = new Meal("hamburger", 7.99); | A new Meal object is created to represent a hamburger that costs $7.99. |
| burger.toString(); | The string "hamburger meal, $7.99" is returned. |
(a) Write the complete Meal class. Your implementation must meet all specifications and conform to the behavior shown in the table.
BoldItalicUnderlineBullet listNumbered listImage (12 image limit)
Edit imageView imageDelete image
0 / 10000 Word Limit
Question 2
A deluxe meal, represented by a DeluxeMeal object, includes a side dish and a drink for an additional cost of $3. The DeluxeMeal class is a subclass of Meal. The DeluxeMeal class contains two additional attributes not found in Meal:
- A String variable representing the name of the side dish included in the meal
- A String variable representing the name of the drink included in the meal
The following table shows the intended behavior of the DeluxeMeal class.
| Statement | Result |
| DeluxeMeal burritoCombo = new DeluxeMeal("burrito", "chips", "lemonade", 7.49); | A new DeluxeMeal object is created to represent a deluxe meal including a burrito (entree), chips (side dish), and lemonade (drink). The cost of the burrito alone is $7.49, so the cost of the meal is set to $10.49. |
| burritoCombo.toString(); | The string "deluxe burrito meal, $10.49" is returned. |
(b) Write the complete DeluxeMeal class. Your implementation must meet all specifications and conform to the behavior shown in the table JUST PART B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
