Question
Please I need output and screenshot only for the following: A class called MyPoint, which models a 2D point with x and y coordinates, is
Please I need output and screenshot only for the following:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started