Selesai

Assistance with modifying a Test program

Proyek ini berhasil diselesaikan oleh DemonDeveloper dengan harga $30 USD dalam sehari.

Dapatkan penawaran gratis untuk proyek seperti ini
Pemberi kerja bekerja
Anggaran Proyek
$10 - $30 USD
Diselesaikan Dalam
1 hari
Total Penawaran
4
Deskripsi Proyek

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));

}

}

Diselesaikan oleh:
Keahlian yang Diperlukan

Ingin menghasilkan uang?

  • Atur anggaran Anda dan jangka waktunya
  • Uraikan proposal Anda
  • Dapatkan bayaran atas pekerjaan Anda

Pekerjakan para freelancer yang juga menawar di proyek ini

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