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)
\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
Get step-by-step solutions from verified subject matter experts
