Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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