package demoEnum;

class TestEnum {
	public static void main(String[] args) {
		Switch hallLight = Switch.ON;
		if (hallLight==Switch.ON) System.out.println("I can see!");
		else System.out.println("It's dark here!");

		String values = "";
		for(Switch x : Switch.values()) {
			values += " " + x;
			System.out.println("Geneology of " + x + " is: " + geneology(x.getClass()));
		}
		System.out.println("Values of Switch are: " + values);

		/*----------Under the Covers-------------------------------------------*/

		SwitchUTC hallLightU = SwitchUTC.ON;
		if (hallLightU==SwitchUTC.ON) System.out.println("I can see!");
		else System.out.println("It's dark here!");

		values = "";
		for(SwitchUTC x : SwitchUTC.values()) {
			values += " " + x;
			System.out.println("Geneology of " + x + " is: " + geneology(x.getClass()));
		}
		System.out.println("Values of SwitchUTC are: " + values);

		/*----------Full Enumerated Type---------------------------------------*/

		int y=2020;
		int doy=Integer.parseInt(args[0]);

		Month.setLeapYear(y);
		Month m = Month.monthFromDOY(doy);
		int dom = Month.domFromDOY(doy);
		System.out.println("In the year " + y + " the " + doy + " day of the year is " + m.abbrev() + " " + dom + " " + y + ".");
		System.out.println("Going backwards, mm/dd/yyyy: " + m.getNumber() + "/" + dom + "/" + y + " is the " + m.doyFromDOM(dom) + " day of the year.");

		System.out.println("Geneology of JANUARY: " + geneology(Month.JANUARY.getClass()));
		System.out.println("Geneology of FEBRUARY: " + geneology(Month.FEBRUARY.getClass()));

		/*-------------------------------------------------------------------*/
	}

	public static String geneology(Class c) {
		String result= "";
		if (c==null) return result;
		result += c.getSimpleName();
		Class sc = c.getSuperclass();
		if (sc != null) result += "->" + geneology(sc);
		return result;
	}
}
