Question: Build a Point2D Class that handles point coordinates (x and v). This class will be composed of a few data items to manage the current

 Build a Point2D Class that handles point coordinates (x and v).

Build a Point2D Class that handles point coordinates (x and v). This class will be composed of a few data items to manage the current position of a point, This Point2D class also allows the user to "print ou point" (toString(), "set the current coordinates"(setXY), and compare two points (equals). Additionally. t the your Point2D class should obey the following conditions called Class Invariants: Class Invariants .All x values should be positive. All y values should be positive. . All points begin at 0,0. Data Items Define some data items to manage the point coordinates Be sure to specify the data type of the items you're declaring (e-g, int, String) Methods For You to Build . public void setXY(int x, int y) o This sets the current position. public String toString) f o Build a "toString()" method that returns a String representation of the position. public boolean equals(Point2D that) f . This method determines if the two point (this and that) are the same. o Consider the following main that will be used to test your PointzD class: public static void main(Stringll args) Point2D pi now Point2D0: Point2D p2 - new Point2DO pl.setxy (3,3) p2.setXY (1,2) System.out.printin(pl.equals (p2)) //prints false

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!