Question: TASK Class Hierarchy: Define a base class called with attributes name and color. This class should have a method display _ info ( ) that
TASK
Class Hierarchy:
Define a base class called with attributes name and color. This class should have a method displayinfo that prints the name and color of the shape.
The base class should also have a method area and perimeter without implementation. You can use the keyword for this.
Implement three subclasses: b Rectangle, and Triangle, each inheriting from the class.
Functionality:
Each subclass should have additional attributes and implement the methods area and perimeter to calculate and return the area and perimeter according to its geometric properties.
Write a simple program that creates instances of each shape class by providing necessary parameters eg radius, length, width
Display the information of each created shape using the displayinfo method.
Calculate and display the area and perimeter for each created shape using the area and perimeter methods.
Look up the formulas for the area and perimeter on the Internet.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
