Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java. Thanks! Practice Polymorphism- Food A Assume you have a parent class called Food with one instance data variable: private String name. The class has
Java. Thanks!
Practice Polymorphism- Food A
Assume you have a parent class called Food with one instance data variable: private String name. The class has one constructor that takes the name as a parameter, getters and setters for name, and a toString that outputs the name.
- Write a child class called Vegetable with one additional variable describing whether or not the vegetable is green.
- Write two constructors: one that takes in all information about a vegetable and one that uses a default value to indicate that a vegetable IS green.
- Write getters and setters, a toString, and an equals method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started