Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Develop multimedia design and programming application which involves drawing various shapes. Specifically, you need to design a class hierarchy to represent different geometric shapes, including
Develop multimedia design and programming application which involves drawing
various shapes. Specifically, you need to design a class hierarchy to represent different
geometric shapes, including "Line," "Circle," and "Rectangle, and probably other
shapes." the following is required:
Create a base class named "Shape" with the following properties:
o fill Color: specifying the color that fills the interior of a shape. o stroke
Color: specifying the color used to draw the outline of a shape
o strokeWidth double: specifying the width of the outline of a shape.
Extend the "Shape" class to create three subclasses:
o "Line": representing lines.
Include attributes: startX, startY, endX, endY double:
representing the coordinates of the line.
"Circle": representing circles.
Include attributes:
radius double: representing the radius of the circle.
centerX, centerY double: representing the center
coordinates of the circle.
"Rectangle": representing rectangles.
Include attributes:
double: representing the topleft coordinates of the
rectangle.
width, height double: representing the dimensions of the
rectangle.
arcWidth, arcHeight double: representing the horizontal
and vertical diameter of the arcs at the corners.
Implement appropriate constructors for each class.
Write setter and getter methods for each class.
Create a program to test these classes. Instantiate objects of each class, set their
attributes, and demonstrate the use of polymorphism by displaying the
properties of each shape.
Implement a method named draw in each class to simulate drawing the shape.
You can print messages like "Drawing a line from startX startY to endX
endY
Add validation for input values eg nonnegative dimensions
Utilize your class hierarchy to draw these shapes in the appropriate colors and
positions to represent the flag of the UAE
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