package edu.iastate.cs228.hw2; public class Pair<E extends Comparable, T extends Comparable> implements Comparable<Pair<E, T>> { private E first; private T second; public Pair(E first, T second){ this.first = first; this.second = second; } @Override public int compareTo(Pair<E, T> other) { if(this.getFirst().compareTo(other.getFirst()) > 0){ return 1; } else if(this.getFirst().compareTo(other.getFirst()) < 0){ return -1; } else { if (this.getSecond().compareTo(other.getSecond()) > 0){ return 1; } else if(this.getSecond().compareTo(other.getSecond()) < 0){ return -1; } else{ return 0; } } } public E getFirst(){ return first; } public T getSecond(){ return second; } }