Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions