UNB/ CS/ David Bremner/ teaching/ cs1083/ java/ IntPair.java
import java.util.ArrayList;
import java.util.Random;
public class IntPair implements Comparable<IntPair> {
    private int left, right;

    public IntPair(int left, int right) {
        this.left=left;
        this.right=right;
    }

    public int compareTo(IntPair other) {
        if (this.left == other.left)
            return (this.right - other.right);
        else
            return (this.left - other.left);
    }

    public String toString() {
        return "(" + left +"," + right + ")";
    }
    public static void main(String [] args){
        ArrayList<IntPair> pairs = new ArrayList<IntPair>();
        Random random = new Random();

        for (int i=0; i<4; i++) {
            pairs.add(new IntPair(random.nextInt(10), random.nextInt(10)));
        }

        for (int i=0; i<pairs.size(); i++) {
            for (int j=0; j<pairs.size(); j++) {
                IntPair a = pairs.get(i);
                IntPair b = pairs.get(j);

                int order = a.compareTo(b);
                String op = "==";
                if (order < 0)
                    op = "<";
                if (order > 0)
                    op = ">";
                System.out.println(a + op + b);
            }
        }
    }
}