// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package bloch;

public class Test {
	public static interface InstrumentedThreeInt extends ThreeInt {
		public int getSetOneCalls();
		public int getSetAllCalls();
	}
	public static class InstrumentedThreeIntA extends ThreeIntA implements InstrumentedThreeInt {
		private int soc = 0;
		private int sac = 0;
		public void setOne(int ix, int v) {
			soc++;
			super.setOne(ix,  v);
		}
		public void setAll(int[] v) {
			sac++;
			super.setAll(v);
		}
		public int getSetOneCalls() {
			return soc;
		}
		public int getSetAllCalls() {
			return sac;
		}
	}
	public static class InstrumentedThreeIntB extends ThreeIntB implements InstrumentedThreeInt {
		private int soc = 0;
		private int sac = 0;
		public void setOne(int ix, int v) {
			soc++;
			super.setOne(ix,  v);
		}
		public void setAll(int[] v) {
			sac++;
			super.setAll(v);
		}
		public int getSetOneCalls() {
			return soc;
		}
		public int getSetAllCalls() {
			return sac;
		}
	}
	public static void main(String[] args) {
		InstrumentedThreeInt a = new InstrumentedThreeIntA();
		a.setAll(new int[] { 1, 2, 3});
		a.setOne(1, -2);
		System.out.printf("%s : %d %d\n", a.getId(), a.getSetOneCalls(), a.getSetAllCalls());
		InstrumentedThreeInt b = new InstrumentedThreeIntB();
		b.setAll(new int[] { 1, 2, 3});
		b.setOne(1, -2);
		System.out.printf("%s : %d %d\n", b.getId(), b.getSetOneCalls(), b.getSetAllCalls());
	}
}
