#code not running

8 messages · Page 1 of 1 (latest)

limber inlet
#
    private int x, y;

    public Point2D() {
        x = 0;
        y = 0;
    }

    public Point2D(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public String toString() {
        return "(" + x + "," + y + ")";
    }

    public boolean compare(Object otherObj) {
        if (this == otherObj) return true;
        Point2D point2D = (Point2D) otherObj;
        return x == point2D.x && y == point2D.y;
    }

    public static void main(String[] args) {
        Point2D point1 = new Point2D(3, 4);
        Point2D point2 = new Point2D(3, 4);
        Point2D point3 = new Point2D(3, 6);
        System.out.println(point1);
        System.out.println(point2);
        System.out.println(point3);
        System.out.println(point1.compare(point2));
        System.out.println(point1.compare(point3));
    }
}```
short oxideBOT
#

This post has been reserved for your question.

Hey @limber inlet! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

limber inlet
#

I’ve put the code on replit, the file is named Point2D.java. I don’t know why when it runs it shows “hello world”

sterile wraith
#

if it's in a folder, java folderName/Point2D.java of course

#

let me know if that works

limber inlet
#

That works thanks 🙏