/
EugenyCh7
/
JavaAndScalaLessons
Обзор
Документация
Войти
/
EugenyCh7
/
JavaAndScalaLessons
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
JavaTest/src/ch4/ex3/Point.java
43 строки
867 B
Eugeny Chekmarev
IDEA update
15 июн 2021, 21:11
15 июн 2021, 21:11
47fadf9
Код
Авторство
О чём код?
package ch4.ex3; import java.util.Objects; public class Point { protected final double x; protected final double y; public Point(double x, double y) { this.x = x; this.y = y; } public Point() { x = y = 0; } public double getX() { return x; } public double getY() { return y; } @Override public String toString() { return String.format("(%f, %f)", x, y); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || (LabeledPoint.class != o.getClass() && getClass() != o.getClass())) return false; Point point = (Point) o; return Double.compare(point.x, x) == 0 && Double.compare(point.y, y) == 0; } @Override public int hashCode() { return Objects.hash(x, y); } }