package com.example.generic;

public class TestStats {

	public static void main(String[] args) {

		Integer[] iNums = { 1, 2, 3, 4, 5 };
		Stats<Integer> iOb = new Stats<>(iNums);
		System.out.println("Integer array average value: " + iOb.average());

		double result = iOb.average();
		System.out.println("Integer array average value: " + result);

		Double[] dNums = { 1.1, 2.2, 3.3, 4.4, 5.5 };
		Stats<Double> dOb = new Stats<>(dNums);
		System.out.println("Double array average value: " + dOb.average());

		// error
		String[] names = { "John", "James", "Jack" };
//		Stats<String> sOb = new Stats<>(names);

		// use wildcard function
		System.out.println("=== Integer vs Double ===");
		if (iOb.compareAvg(dOb)) {
			System.out.println("Same average for both Integer and Double");
		} else {
			System.out.println("Different average for both Integer and Double");
		}

		if (dOb.compareAvg(iOb)) {
			System.out.println("Same average for both Integer and Double");
		} else {
			System.out.println("Different average for both Integer and Double");
		}
	}

}
