feat: change up organisation
This commit is contained in:
37
labs/cs2030s/Lab9/Lab9b/Pair.java
Normal file
37
labs/cs2030s/Lab9/Lab9b/Pair.java
Normal file
@@ -0,0 +1,37 @@
|
||||
class Pair<T,S> {
|
||||
private T fst;
|
||||
private S snd;
|
||||
public Pair(T fst, S snd) {
|
||||
this.fst = fst;
|
||||
this.snd = snd;
|
||||
}
|
||||
public T getFst() {
|
||||
return this.fst;
|
||||
}
|
||||
public S getSnd() {
|
||||
return this.snd;
|
||||
}
|
||||
public void setFst(T fst) {
|
||||
this.fst = fst;
|
||||
}
|
||||
public void setSnd(S snd) {
|
||||
this.snd = snd;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + this.fst + ", " + this.snd + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if(!(obj instanceof Pair<?,?>)) {
|
||||
return false;
|
||||
}
|
||||
Pair<?,?> pr = (Pair<?,?>) obj;
|
||||
return this.fst.equals(pr.fst) &&
|
||||
this.snd.equals(pr.snd);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user