Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a hierarchy of Java classes as follows: MyLine is_a MyShape; MyPolygon is_a MyShape; MyCircle is_a MyShape. Class MyShape: Class MyShape is the hierarchys superclass

Create a hierarchy of Java classes as follows:

MyLine is_a MyShape; MyPolygon is_a MyShape; MyCircle is_a MyShape.

Class MyShape:

Class MyShape is the hierarchys superclass and inherits Java class Object. An implementation of the class defines a point (x, y) and the color of the shape. The class includes appropriate class constructors and methods that perform the following operations:

getX, getY, getColor returns the point (x, y) and color of the MyShape object;

setX, setY, setColor sets the point (x, y) and color for the MyShape object;

shiftXY moves point (x, y) by (x, y);

toString - returns the object's description as a String. This method must be overridden in each subclass in the hierarchy.

draw This method must be overridden in each subclass in the hierarchy. For the MyShape object, it paints the drawing canvas in color.

Class MyLine:

Class MyLine inherits class Shape. The MyLine object is a straight line defined by its two endpoints (x1, y1) and (x2, y2). The MyLine object may be of any color. The class includes appropriate class constructors and methods that perform the following operations:

getLength returns the length of the MyLine object;

get_xAngle return the angle (in degrees) of the MyLine object with the x-axis;

toString returns a string representation of the MyLine object: length and angle

with the x-axis;

draw draws a MyLine object whose end points are (x, y) (x1, y1) and (x2, y2).

Class MyPolygon:

toString

returns the object's description as a String. This method must be

overridden in each subclass in the hierarchy.

This method must be overridden in each subclass in the hierarchy. For the

object, it paints the drawing canvas in color

Class MyPolygon inherits class MyShape. The MyPolygon object is a regular polygon defined by the integer parameter N the number of the polygons equal side lengths and equal interior angles. The MyPolygon object may be filled with a color. The class includes appropriate class constructors and methods that perform the following operations:

getArea returns the area of the MyPolygon object;

getPerimeter returns the perimeter of the MyPolygon object;

getAngle return the interior angle (in degrees) of the MyPolygon object;

getSide returns the side length of the MyPolygon object;

toString returns a string representation of the MyPolygon object: side length,

interior angle, perimeter, and area;

draw draws a MyPolygon object whose center point (x, y) is defined in class

MyShape and inscribed in a circle of radius radius.

Class MyCircle:

Class MyCircle inherits class Shape. The MyCircle object is defined by its radius, radius, and center (x, y), and may be filled with a color. The MyCircle class includes appropriate class constructors and methods that perform the following operations:

getArea returns the area of the MyCircle object;

getPerimeter returns the perimeter of the MyCircle object;

getRadius returns the radius of the MyCircle object;

toString returns a string representation of the MyCircle object: radius,

perimeter, and area;

draw draws a MyCircle object of radius radius. The center point (x, y) of the

circle is defined in class MyCircle Shape.

2- Use JavaFX graphics and the class hierarchy to draw a geometric configuration comprised of a sequence of alternating concentric pentagons and circles as illustrated below, subject to the following additional requirements:

The code is applicable to canvases of variable height and width;

The dimensions of the shapes are proportional to the smallest dimension of the

canvas;

The pentagons and circles are filled with different colors of your choice.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago