blob: c296c7ca13ff8375b16e02cce239fc5858b9492a (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* Jesse Morgan <jesterpm@u.washington.edu>
*
* TCSS 305 - Autumn 2009
* Tetris Project
* 17 November 2009
*/
package tetris.model;
/**
* Class to represent an int point in two-space.
*
* @author Jesse Morgan <jesterpm@u.washington.edu>
* @version 1.0 17 November 2009
*/
public class IntPoint {
/**
* The x-coordinate.
*/
private final int my_x;
/**
* The y-coordinate.
*/
private final int my_y;
/**
* Create a new point.
*
* @param the_x The x-coordinate.
* @param the_y The y-coordinate.
*/
public IntPoint(final int the_x, final int the_y) {
my_x = the_x;
my_y = the_y;
}
/**
* @return The x-coordinate.
*/
public int getX() {
return my_x;
}
/**
* @return The y-coordinate.
*/
public int getY() {
return my_y;
}
/**
* Compare IntPoint to another object.
* @param the_other The object to compare to.
* @return True if x and y are the same. False otherwise.
*/
public boolean equals(final Object the_other) {
boolean result = false;
if (the_other != null && the_other.getClass() == getClass()) {
final IntPoint other_point = (IntPoint) the_other;
if (getX() == other_point.getX() && getY() == other_point.getY()) {
result = true;
}
}
return result;
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public String toString() {
return "(" + getX() + "," + getY() + ")";
}
}
|