@NikitaWeb

Не проходит тест. В чем проблема?

Есть такой код:
package net.thumbtack.school.windows.v1;

import java.util.Objects;

public class Point {

    private int x, y;

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

    public Point() {
        Point zero = new Point(0,0);
    }

    public Point(Point point) {
        Point point1 = point;
    }

    public int getX() {
        return this.x;
    }

    public int getY() {
        return this.y;
    }

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

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

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

    public void moveRel(int dx, int dy) {
        this.x += dx;
        this.y += dy;
    }

    public boolean isVisibleOnDesktop(Desktop desktop) {
        if (x <= 0 || y <= 0) return false;
        if (x <= desktop.getWidth() && y <= desktop.getHeight()) return true;
        else return false;
    }

    public boolean isNotVisibleOnDesktop(Desktop desktop) {
        if (x <= 0 || y <= 0) return true;
        if (x <= desktop.getWidth() && y <= desktop.getHeight()) return false;
        else return true;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Point point = (Point) o;
        return x == point.x ||
                y == point.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Он не проходит данный тест:
5bf2d844ed74e573391935.png
Каким должен быть код, чтобы пройти этот тест?
  • Вопрос задан
  • 219 просмотров
Решения вопроса 1
@Cheypnow
1.
public Point(Point point) {
        this.x = point.x;
        this.y = point.y;
    }


2.
@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Point point = (Point) o;
        return x == point.x && y == point.y;
    }
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы