Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock

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... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!