Completed

Assistance with modifying a Test program

This project was successfully completed by DemonDeveloper for $30 USD in a day.

Get free quotes for a project like this
Employer working
Project Budget
$10 - $30 USD
Completed In
1 day
Total Bids
4
Project Description

The "Point" class has two fields (x and y), one constructor, and four methods(getx(), getY(), equals(), and toString()). I also have a separate "TestPoint" class that does have main() method after the Point class.

I need to modify the "TEST POINT" program below so that it defines q to have the same coordinates as p. Then, check that [url removed, login to view](p) is true and that q == p is false, thereby verifying that two distinct objects can be separate but equal.

public class Point {

private int x, y; // the point's coordinates

public Point(int x, int y){

this.x = x;

this.y = y;

}

public boolean equals(Point p){

return (x == p.x && y == p.y);

}

public int getX(){

return x;

}

public int getY(){

return y;

}

public String toString(){

return new String("(" + x + ", " + y + ")");

}

}

public class TestPoint {

public static void main(String[] args) {

Point p = new Point(2, -3);

[url removed, login to view]("p: " + p);

[url removed, login to view]("[url removed, login to view](): " + [url removed, login to view]());

[url removed, login to view]("[url removed, login to view](): " + [url removed, login to view]());

Point q = new Point(7,4);

[url removed, login to view]("q: " + q);

[url removed, login to view]("[url removed, login to view](p): " + [url removed, login to view](p));

[url removed, login to view]("[url removed, login to view](q): " + [url removed, login to view](q));

}

}

Completed by:
Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online