class SimpleObject {

	private int value;
	
	public int getValue() {
		return this.value;
	}
	
	public void setValue(int value) {
		this.value = value;
	}
	
	public String toString() {
		return Integer.toString(this.value);
	}

}

class ExtendedSimpleObject extends SimpleObject {


	public int getValue() {
		int value = super.getValue();
		if (value<0)
			return -value;
		return value;
	}
	
	public void setValue(int value) {
		if (value<0)
			super.setValue(0);
		else
			super.setValue(value);
	}
}


public class Test3c {

	public static void main (String[] args) {
	
		int max = 100000000;
		if (args.length>0) {
			try {
				max = Integer.parseInt(args[0]);
			} catch (Exception e) {
				System.err.println("Bag args : " + args[0] + " (ignored).");
			}
		}
	
	
		System.out.println("Test3c :: Les accesseurs/mutateurs (heritage)");
		System.out.println(System.getProperty("java.vm.name") + " "
			+ System.getProperty("java.vm.version") + " ("
			+ System.getProperty("java.vm.vendor") +").");
		
		System.out.println();
		
		
		
		long start = System.currentTimeMillis();
		System.out.println("Iteration  : " + max);
		SimpleObject[] object = new SimpleObject[2];
		object[0] = new SimpleObject();
		object[1] = new ExtendedSimpleObject();
		for (int i=0; i<max; i++) {
			SimpleObject tmp = object[i%2];
			tmp.setValue( i + tmp.getValue() );
		}
		System.out.println("Resultat   : " + object[0] + ", " + object[1]);
		long end = System.currentTimeMillis();
		
		System.out.println();
		System.err.print("PROCESS TIME : " + (end-start) + " ms");
	}
}