class Pair <T, S> {
	private T _objLeft;
	private S _objRight;
	
	public Pair(T pobjLeft, S pobjRight) {
		_objLeft = pobjLeft; 
		_objRight = pobjRight; 
	}
	public T getLeft() { return _objLeft; }
	public S getRight() { return _objRight; }
}

class GenericTripleInh <T, U, V> extends Pair <T, V> { // (a)
	private U _objMid; // extending left and right is cleanest
		// otherwise, inherited getters will return wrong data
	public GenericTripleInh(T pobjLeft, U pobjMid, V pobjRight) {
		super(pobjLeft, pobjRight);
		_objMid = pobjMid;
	}
	public U getMid() { return _objMid; }
}

class GenericTripleComp <T, U, V> { // (b)
	private Pair<T, Pair<U,V>> _objPair;
	
	public GenericTripleComp(T pobjLeft, U pobjMid, V pobjRight) {
		_objPair = new Pair<T, Pair<U,V>>(pobjLeft,
			new Pair<U,V>(pobjMid, pobjRight));
	}
	public T getLeft() { return _objPair.getLeft(); }
	public U getMid() { return _objPair.getRight().getLeft(); }
	public V getRight() { return _objPair.getRight().getRight(); }
}

/* (c), (d) - Can interchange between GenericTripleInh & GenericTripleComp */

class PersonInh extends GenericTripleComp <String, Double, Double> { // (c)
	public PersonInh(String pstrName, double pdblWt, double pdblHt) {
		super(pstrName, pdblWt, pdblHt); }
	public String getName() { return getLeft(); }
	public double getWt() { return getMid(); }
	public double getHt() { return getRight(); }
} // now we have 3 inherited getter methods left hanging...

class PersonComp { // (d) 
	private GenericTripleInh<String, Double, Double> _objTriple;
	public PersonComp(String pstrName, double pdblWt, double pdblHt) {
		_objTriple = new GenericTripleInh<String, Double, Double>(
			pstrName, pdblWt, pdblHt);
	}
	public String getName() { return _objTriple.getLeft(); }
	public double getWt() { return _objTriple.getMid(); }
	public double getHt() { return _objTriple.getRight(); }
} // why does a Double work, even though defined return type is double?

public class TestPeople {
	public static void main(String[] args) {
		/* insert your test data here! */
	}
}
