Question: 1) Create an abstract class called Shape, which stores are array of Point2D objects and has queries for the points which represent the vertices, each

1) Create an abstract class called Shape, which stores are array of Point2D objects and has queries for the points which represent the vertices, each accessed by an index.

public class Point2D {

private double[] coords;

/** default constructor - this constructor calls the other one giving default x and y coordinates of 0.0 , 0.0

@custom.ensure getX() == 0.0 @custom.ensure getY() == 0.0

*/ public Point2D() { this(0.0,0.0); }

/** overloaded constructor taking two doubles as arguments for the x and y coordinates

@param x The initial horizontal coordinate of this point2D @param y The initial vertical coordinate of this point2D

@custom.ensure getX() == x @custom.ensure getY() == y */

public Point2D(double x, double y) { coords = new double[2]; coords[0] = x; coords[1] = y; }

/** @return The horizontal coordinate of this point2D */ public double getX() { return coords[0]; }

/** @return The vertical coordinate of this point2D */ public double getY() { return coords[1]; }

} // end class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!