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, 22.06.2019 17:00
Acase study allows a more detailed look at the life of a single subject than any other study.
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
If joey was single and his taxable income was $9,500, how much would he pay in taxes each year?
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
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, 14.01.2022 16:10
question
Mathematics, 14.01.2022 16:10
question
Health, 14.01.2022 16:20
question
Mathematics, 14.01.2022 16:20
Questions on the website: 13722361