Question: Add the following methods to the Point class: public String toString ( ) Make it return a string in the following format : [ x

Add the following methods to the Point class:
public String toString()
Make it return a string in the following format : [x=5, y=-17]. For example, if a Point object stored in a variable pt represents the point (5,-17), return the string: [x=5,y=-17]
public boolean isQuadrant()
Returns true if this Point object is located in Quadrant 1 of the x/y plane. Quadrant 1 contains all points whose x and y values are both positive. Returns false otherwise. If the point lies directly on the x and/or y axis return false.
public void swap ()
Negates and swaps the x/y coordinates of the Point object. For example, if the object initially represents the point (1,-2), after a call to flip, the object should represent (2,-1). If the object initially represents the point (3,4), after a call to swap, the object should present (-4,-3).
Please note that swapping values takes three steps : For example, to swap x and y, x=y and y=x will store same contents. Instead,
int temp = x; // store old x value to temp
x = y;// update x with y
y = temp;// update y with old x
public boolean equals(Point other)
Returns true if the object to be compared has same x and y coordinates. false otherwise.
public Point (Point p)
Write a 3rd constructor that constructs and initializes a point with the same location as the specified Point object.
public Point makeCopy ()
Creates a new Point object with the same contents as this Point object. The method should then return the new Point object you created. Please note that you can create a new Point object using
Point p = new Point () or Point p = new Point (x, y)
Your code is being added to the Point class we wrote in class. Demonstrate all of the above methods in PointClient.java by calling them appropriately. Submit Point.java and PointClient.java on Canvas.

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 Programming Questions!