point.java

来自「高质量Java程序设计 源代码」· Java 代码 · 共 42 行

JAVA
42
字号
package net.betterjava.design.inheritance.restriction;

public class Point {
	double x;
	double y;

	public boolean equals(Object o) {
		if (!(o instanceof Point)) {
			return false;
		}

		Point temp = (Point) o;
		if (this.x == temp.getX() && this.y == temp.getY()) {
			return true;
		} else {
			return false;
		}
	}

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

	public double getX() {
		return x;
	}

	public double getY() {
		return y;
	}

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

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

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?