Question: 1. Create a Superclass Food: a. With three attributes to store: 1) calories per 100gr 2) weight (in pounds] 3) price b. toString() method which

 1. Create a Superclass Food: a. With three attributes to store:

1. Create a Superclass Food: a. With three attributes to store: 1) calories per 100gr 2) weight (in pounds] 3) price b. toString() method which returns a String that indicates the calories per pound, weight and price C. Abstract method compute TotalCalories(). d. Abstract method information(). 2. Extend a Meat class from the Food class: a. With one attribute: type of the meat (.e. chicken, beef, fish, etc). b. Override toString() method of the Food class, and return the type of the meat. C. Override compute TotalCalories(): weight*calories*4.54 d. Override information(): method to print that "This is a ... pound box of... meat. The calories in this type of meat per 100 grams are ... so it has a total of ... calories. 3. Extend a Vegetable class from the Food class: a. With two attribute: name of the vegetable and cooked as Boolean b. Override toString() method of the Food class, and return the name of the vegetable and whether it is cooked or not. c. Override compute TotalCalories(): (cooked)? 20 + weight*calories *4.54: weight calories 4.54 d. Override information(): method to print that. This is a ... pound box of (cooked/raw)... and the calories per 100 gram for this vegetable are... so it has a total of ... calories. 4. Create a Driver class that: a. Create an array of four Food types, Create two Meats and store it in the array, Create two Vegetables and store it in the array. b. Iterate over the array and print the message of the food by calling the information() methods. C. Iterate over the array and print the total calories of all the Vegetables and the total calories of all the Meats. You may use input like: Meat meat1=new Meat(300, 8, $25, "beef"); Vegetable veg1=new Vegetable(50, 7. $9, "broccoli", true)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!