subject
Computers and Technology, 08.01.2021 17:30 KallMeh

For this exercise, you are going to create a Food superclass with a HealthyFood subclass. The HealthyFood will also have a Fruit subclass. After creating these classes, test the results in the FoodTester class. The Food class will have two instance variables, one to store the name and one to store the calories.
Food should have two accessor (getter methods) as well:
public String getName()
public int getCal()
The HealthyFood class will only have one instance variable, group, which represents the food group and should have the following accessor (getter method):
public String getGroup()
The Fruit class will have two instance variables, a boolean indicator if the fruit is local and the color. The accessor methods should be:
public boolean isLocal()
public String getColor()
Constructors should follow this format:
public Food (String foodName, int calories)
public HealthyFood(String foodName, int calories, String foodGroup)
public Fruit(String foodName, int calories, boolean isLocal, String foodColor)
Finally, the Food class should have a toString that prints:
name has cal calories
For example:
Ice Cream has 200 calories
Code Given:

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Best laptops for college [$100-$500 range]?
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
Which of the following is not an enhancement to the standard wiki to make it more attractive for corporations? encryptionwork spacespermission toolspredictive text
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
question
Computers and Technology, 23.06.2019 18:30
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
You know the right answer?
For this exercise, you are going to create a Food superclass with a HealthyFood subclass. The Health...
Questions
question
Mathematics, 26.03.2020 22:02
question
Mathematics, 26.03.2020 22:02
question
Mathematics, 26.03.2020 22:02