Answer the question
In order to leave comments, you need to log in
Doesn't pass the test. What is the problem?
There is this code:
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);
}
}
Answer the question
In order to leave comments, you need to log in
one.
public Point(Point point) {
this.x = point.x;
this.y = point.y;
}
@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;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question