Question: A class called MyPoint, which models a 2D point with x and y coordinates, is designed as shown in the class diagram. It contains: Two

A class called MyPoint, which models a 2D point with x and y coordinates, is designed as shown in the class diagram. It contains: Two instance variables x (int) and y (int). A "no-argument" (or "no-arg") constructor that construct a point at (0, 0). A constructor that constructs a point with the given x and y coordinates. Getter and setter for the instance variables x and y. A method setXY() to set both x and y. A method called distance(int x, int y) that returns the distance from this point to another point at the given (x, y) coordinates. An overloaded distance(MyPoint another) that returns the distance from this point to the given MyPoint instance another.

(please use your keyboard and provide output and screenshots thank you) A class called MyPoint, which models a 2D point with x

\begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ MyPoint } \\ \hline - x: int =0 \\ -y:int =0 \\ \hline +MyPoint() \\ +MyPoint( x: int, y: int ) \\ +getX( ):int \\ +setX(x:int ): void \\ +getY( (): int \\ +setY( y: int ): void \\ +setXY (x: int, y: int ): void \\ +toString (): String \\ +distance (x: int, y: int ): double \\ +distance ( another:MyPoint ): double \\ \hline \end{tabular}

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!