[Solved] CSC22100 Exercise2

$25

File Name: CSC22100_Exercise2.zip
File Size: 169.56 KB

SKU: [Solved] CSC22100 Exercise2 Category: Tag:
5/5 - (1 vote)
  • Amend the hierarchy of Java classes in Exercise 1 as follows:

MyLine is_a MyShape;

MyPolygon is_a MyShape;

MyRectangle is_a MyShape MyOval is_a MyShape; MyCircle is_a MyOval.

  • Class MyShape is an abstract class; is the hierarchys superclass; and inherits Java class Object. The draw method in class MyShape is an abstract method and hence must be overridden in each subclass in the hierarchy. Otherwise, the classes MyShape, MyLine, MyPolygon, and MyCircle are defined as in Exercise 1 but now utilize.

Class MyRectangle:

Class MyRectangle inherits class MyShape. The MyRectangle object is a rectangle of height h and width w, centered at a point (x, y), and may be filled with a color. The class includes appropriate class constructors and methods, including methods that perform the following operations:

  1. getWidth, getHeight, getPerimeter, getArea return the width, height, perimeter, and area of the MyRectangle object;
  2. setWidths, etHeight, setPerimeter, setArea set the width, height, perimeter, and area of the MyRectangle object;
  3. toString returns a string representation of the MyRectangle object: width, height, perimeter, and area;
  4. draw draws a MyRectangle object of height h and width w, centered at a

point (x, y). The center point of the rectangle is defined in class MyShape.

Class MyOval:

Class MyOval inherits class MyShape and may use class MyRectangle. The MyOval object is defined by an ellipse inscribed in a rectangle of height h and width w, centered at a point (x, y). The MyOval object may be filled with a color.

The class includes appropriate class constructors and methods, including methods that perform the following operations:

  1. getPerimeter returns the perimeter of the MyOval object;
  2. getArea returns the area of the MyOval object;
  3. toString returns a string representation of the MyOval object: axes lengths, perimeter, and area;
  4. draw draws a MyOval object inscribed in a rectangle of height h and width w, centered at a point (x, y). The center point of the oval is defined in class

MyShape.

  • Interface MyPoint and interface MyShapePosition are specified in connection with the class hierarchy. The abstract class MyShape implements interface MyShapePosition which extends interface MyPoint. All classes of the hierarchy must be amended in accordance with the two interfaces.
  • Interface MyPoint includes appropriate abstract, static, and/or default methods that describe the positional functions and behaviors of the specific object types of the class hierarchy, including:
  1. getPoint, setPoint return and set the point (x, y);
  2. moveTo moves point (x, y) to point (x + x, y + y);
  3. distanceTo returns distance from point (x, y) to a point;
  • Interface MyShapePosition includes appropriate abstract, static, and/or default methods that describe the functions and behaviors of the specific object types of the class hierarchy, including:
  1. getMyBoundingBox returns the bounding rectangle of an object in the class hierarchy;
  2. doOverlap returns true if two objects in the class hierarchy do overlap; false otherwise.
  • Use JavaFX graphics and the class hierarchy to draw a geometric configuration comprised of a sequence of alternating concentric ovals and their inscribed rectangles as illustrated below, subject to the following additional requirements:
  1. The code is applicable to canvases of variable height and width;
  2. The dimensions of the shapes are proportional to the smallest dimension of the canvas;
  3. The recatngles and ovals are filled with different colors of your choice, specified through a MyColor enum data type.

Explicitly specify all the classes imported and used in your Java code.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSC22100 Exercise2
$25