Question: Programming Exercise 0 4 1 . Shape Hierarchy: - Create a base class called Shape with the following attributes and methods: - Attributes: ` color
Programming Exercise
Shape Hierarchy:
Create a base class called Shape with the following attributes and methods:
Attributes: colorString and filledboolean
Methods:
getAreaabstract method
getPerimeterabstract method
toString method that returns a string representation of the shape.
Create two subclasses, Circle and Rectangle that are inherited from the Shape class.
Circle should have a radius attribute.
Rectangle should have width and length attributes.
Implement appropriate constructors and override the abstract methods in the subclasses.
Polymorphic Array:
In the main class, create an array of Shape objects.
Populate the array with instances of Circle and Rectangle
Display the details color filled, area, and perimeter of each shape using polymorphism.
Interface:
Define an interface called Resizable with a method resizedouble factor that represents resizing a shape.
Make the Rectangle class implement the Resizable interface.
In the main class, demonstrate polymorphism by resizing a Rectangle object using the Resizable interface.
An example of the program is shown below:
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
