Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

not sure where to go from here. Any help would be appreciated. public class myPoint { private int x; private int y; myPoint(){ x =

not sure where to go from here. Any help would be appreciated.

public class myPoint { private int x; private int y; myPoint(){ x = 0; y = 0; }

myPoint (int x, int y) { this.x = x; this.y = y; } int getX() { return this.x; } void setX(int x) { this.x = x; } int getY() { return this.y; } void setY(int y) { this.y = y; } void setXY(int x, int y) { this.x = x; this.y = y; } public String toString() { return "[" + x + ":" + y + "]"; }

public double distance(int x, int y) { double tbeDistance = 0; theDistance = Math.sqrt((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y)); return theDistance; } public double static boolean (myPoint another) { }

}

image text in transcribed

Develop a class called MyPoint, which models a point in 2D plane with x and y coordinates, as is shown in the class diagram. It contains: Toanceviablesdesenng ie Ce coedinates of A "no-argument (or "no-arg") constructor that construct a point at (o, 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 tostring method that returns a string description of the instance in the format (x, y 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 You are required to: Write the code for the class MyPoint. Make an array of 5 MyPoint objects Write a static boolean method contains() that takes as parameters an array of MyPoint 2. 3. arr, and one Mypoint, p. It returns true if the array arr contains myPoint p. (two myPoints are considered equal if both their instance variables x and y, are equal. Write a static boolean method horizontalo that takes as a parameter an array of Nypoint l returns true if the points are all on a horizontal line. 5. Write a main0) method that tests your class MyPoint by running tests on all the methods defined in the class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

=+5 Evaluate whether the CCT program was effective.

Answered: 1 week ago

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago