Computers and Technology
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:

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 08:00, leleee10
Which argument is not a valid filter? does not equal this quarter filter by cell color all of these are valid filter arguments.
Answers: 2
image
Computers and Technology, 23.06.2019 21:30, quintonps12
Which of the following includes the three primary network access technologies? dsl, cable modem, broadband lan, wan, man voip, uc, iptv tcp/ip, ftp, dhcp
Answers: 2
image
Computers and Technology, 24.06.2019 03:00, paguy12
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, pineapplepizaaaaa
If you add the following to the query grid in an access query, what is it called? salestaxamt: [salestaxrate]*[totalsale] formula calculated field total calculation
Answers: 2
Do you know the correct answer?
For this exercise, you are going to create a Food superclass with a HealthyFood subclass. The Health...

Questions in other subjects:

Konu
Mathematics, 29.05.2020 20:58
Konu
Physics, 29.05.2020 20:58
Konu
Mathematics, 29.05.2020 20:58