summaryrefslogtreecommitdiff
path: root/java/src/org/singinst/uf/math/SimplePoint.java
blob: e1f9ac1d66dcd7304a78e256cef6930e3e9e948c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.singinst.uf.math;

import java.util.Arrays;

public class SimplePoint {

	public SimplePoint(double x, double y) {
		this.x = x;
		this.y = y;
	}
	public final double x;
	public final double y;
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof SimplePoint) {
			SimplePoint other = (SimplePoint) obj;
			return other.x == x && other.y == y;
		} else {
			return false;
		}
	}
	@Override
	public int hashCode() {
		return canon().hashCode();
	}
	@Override
	public String toString() {
		return canon().toString();
	}
	
	private Object canon() {
		return Arrays.asList(x, y);
	}

	
}