Question
Suppose we want to implement a drawing program that creates various shapes using keyboard characters. Implement an abstract base class DrawableShape that know the center
Suppose we want to implement a drawing program that creates various shapes using keyboard characters. Implement an abstract base class DrawableShape that know the center (two integer values) and the color (a string) of the object. Give appropriate accessor methods for the attributes. Also a mutator method that moves the object by a given amount.
Create a class Square derived from DrawableShape. A Square object should know the length of its sides. The class should have an accessor method and a mutator method for this length. It should also have methods for computing the area and perimeter of the square. Although characters are taller than they are wide - so the number of characters in the vertical sides will differ from the number in the horizontal sides, do not worry about this detail.
Create a test class that creates an array of 10 instances of Square and sort them.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To tackle this problem we need to create an abstract base class named DrawableShape and a derived class Square Lets break down the solution into manag...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