// Purpose: Support the representation of a three-tuple.	
	
public class Triple {	
	// instance variables for the three attributes	
	private int x1;    // first value	
	private int x2;    // second value	
	private int x3;    // third value	
	
	// Triple(): default constructor	
	public Triple() {	
		this(0, 0, 0);	
	}	
	
	// Triple(): specific constructor	
	public Triple(int a, int b, int c) {	
		setValue(1, a);	
		setValue(2, b);	
		setValue(3, c);	
	}	
	
	// getValue(): attribute accessor	
	public int getValue(int i) {	
		switch (i) {	
			case 1: return x1;	
			case 2: return x2;	
			case 3: return x3;	
			default:	
				System.err.println("Triple: bad get: " + i);	
				System.exit(i);	
				return i;	
		}	
	}	
	
	// setValue(): attribute mutator	
	public void setValue(int i, int value) {	
		switch (i) {	
			case 1: x1 = value; return;	
			case 2: x2 = value; return;	
			case 3: x3 = value; return;	
			default:	
				System.err.println("Triple: bad set: " + i);	
				System.exit(i);	
				return;	
		}	
	}	
	
	// toString(): string representation facilitator	
	public String toString() {	
		int a = getValue(1);	
		int b = getValue(2);	
		int c = getValue(3);	
	
		return "Triple[" + a + ", " + b + ", " + c + "]";	
	}	
	
	// clone(): duplicate facilitator	
	public Object clone() {	
		int a = getValue(1);	
		int b = getValue(2);	
		int c = getValue(3);	
	
		return new Triple(a, b, c);	
	}	
	
	// equals(): equals facilitator	
	public boolean equals(Object v) {	
		if (v instanceof Triple) {	
			int a1 = getValue(1);	
			int b1 = getValue(2);	
			int c1 = getValue(3);	
	
			Triple t = (Triple) v;	
			int a2 = t.getValue(1);	
			int b2 = t.getValue(2);	
			int c2 = t.getValue(3);	
	
			return (a1 == a2) && (b1 == b2) && (c1 == c2);	
		}	
		else {	
			return false;	
		}	
	}	
}	
	
