Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Study the UML diagram from Figure 1. Create an abstract class Shape and class Coordinates. Class Coordinates has two fields-an array of X-coordinates and
Study the UML diagram from Figure 1. Create an abstract class Shape and class Coordinates. Class Coordinates has two fields-an array of X-coordinates and an array of Y-coordinates. The size of the arrays is defined by the static constant MAX_VERT which holds the maximum number of vertices a shape in the project may have. The relationship between these two classes is an aggregation: "Shape has Coordinates." Field shape in class Shape holds the type of each object created. Possible types are Line, Triangle, and Parallelogram. It is recommended to create an enumerated class ShapeType for possible types of shapes. Such a class may be defined inside the class Shape or as a separate file. If you experience difficulties with enumerated types, you can use an array of strings instead. Static method distance () in class Shape returns the distance between two points given by its coordinates. It can be used by any derived class. Make method perimeter () in class Shape an abstract method, so any derived class has to implement it. enum ShapeType Line Triangle Parallelogram Line +Line(coord: Coordinates) perimeter():double +toString(): String Shape #shape: ShapeType #coord: Coordinates +Shape(coord: Coordinates) +distancefxl.v1 2.v2.indouble perimeter():double +toString():String Triangle +Triangle(coord: Coordinates) perimeter():double +toString() String Coordinates -MAX VERT int +x:int[] +y:int Coordinates(x,y:int[]) Parallelogram +Parallelogram(coord: Coordinates) +perimeter():double +isRectangle():boolean +toString(): String
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the implementation for the Shape and Coordinates classes as per the instructions given in Step 1 public abstract class Shape protected ShapeType type protected Coordinates coordinates public Sha...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