Question: Question 8 (15 MARKS] A class Vegetable has the following attributes: name, a string that identifies the vegetable colour, a string that indicates the colour
![Question 8 (15 MARKS] A class Vegetable has the following attributes:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f0f8a910a81_32866f0f8a874493.jpg)
Question 8 (15 MARKS] A class Vegetable has the following attributes: name, a string that identifies the vegetable colour, a string that indicates the colour of the vegetable edible, a boolean that indicates whether the vegetable is edible or not and the following methods: a constructor to set all the properties isEdible that will return whether the Vegetable is edible or not whatColour that will return the colour of the vegetable display that will display all the instances created of class Vegetable A class Leaf is derived from the class Vegetable. The Leaf class has one attribute: cooked, a boolean value that is true if the vegetable can be cooked or not and the following methods: a constructor to set all the properties cookIt that will set the property cooked to true isCooked that will return the value of the property cooked display that extends the base class method to display the value of the attribute cooked 8.1 Implement the classes Vegetable and Leaf. (10) 8.2 Write a java program to test you implementation. Your program must do the following: a. Create a yellow edible Vegetable object named corn b. Display the colour of the corn object. C. Create a green edible Leafy object named spinach that can be cooked. d. Cook the spinach and call isCooked to verify that it is cooked. e Display whether spinach is edible or not. UNISA 2019
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
