-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.java
More file actions
49 lines (40 loc) · 919 Bytes
/
Tuple.java
File metadata and controls
49 lines (40 loc) · 919 Bytes
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
package reversi;
public class Tuple<A,B> {
private A fir;
private B sec;
public Tuple(A fir, B sec) {
this.fir=fir;
this.sec=sec;
}
public A first(){
return fir;
}
public B second() {
return sec;
}
public void first(A in){
fir=in;
}
public void second(B in){
sec=in;
}
//For debugging
@Override
public String toString(){
return String.format("(%d,%d)", fir, sec);
}
//We need equals to use the distinct() method in ReversiController
@Override
public boolean equals(Object obj) {
if (obj.getClass() == this.getClass()){
Tuple<A,B> other = (Tuple<A,B>) obj;
return (other.first()==fir && other.second()==sec);
}
return false;
}
//Ditto
@Override
public int hashCode(){
return toString().hashCode();
}
}