There is a
Food class (whose implementation is not shown) with a private
numCalories integer instance variable.
Food has a
chomp() method that returns nothing and prints
"{numCalories}
calories consumed" (e.g.,
"5 calories consumed"). There should also be a
Fruit subclass that inherits from
Food and adds the private
color String instance variable. The
Fruit class should override the
Food chomp() method to return nothing, print
"{numCalories} calories consumed", and print
"fruit is {color}" (on a new line). Finally, there should be an
Apple subclass that inherits from
Fruit, sets
color to
"red", and adds a
variety String private instance variable. The
Apple class should have an overriden
chomp() method that returns nothing, prints
"{numCalories}
calories consumed", prints
"fruit is {color}", and prints
"ate {variety} apple" (all separated by new lines). Remember that the
numCalories and
color variables are private, so the
Apple class does NOT have access to their values. But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.