/*
 * Code20.java
 * Dan Armendariz
 * Computer Science 76
 * Building Mobile Applications
 *
 * Demonstrates class inheritance.
 *
 */

class Code20 {

	private static Computer macPro;
	private static Laptop macBookAir;
	private static Server xserve;

	private static void showRunningMachines() {
		System.out.println();
		
		System.out.println("The following machines are turned on:");

		if(macPro.isOn()) System.out.println("- "+macPro.model);
		if(macBookAir.isOn()) System.out.print("- "+macBookAir.model);
		if(xserve.isOn()) System.out.println("- "+xserve.model);

		System.out.println();

	}

	public static void main(String [] args) {

		macPro = new Laptop("Apple", "MacPro", 2009, 2.8);
		macBookAir = new Laptop("Apple", "MacBook Air", 2009, 1.8);
		xserve = new Server("Apple", "Xserve", 2010, 3.2);

		macPro.turnOn();
		macBookAir.turnOn();

		macBookAir.setBattery(0.5);
		xserve.setRackHeight(1);
		
		System.out.println(macPro.built + " " + macPro.make + " " + macPro.model 
							+ " runs at " + macPro.speed + "ghz.");

		System.out.println(macBookAir.built + " " + macBookAir.make + " " +
						   macBookAir.model + " runs at " + macBookAir.speed + 
						   "ghz and has a battery level of "+
						   (macBookAir.getBattery() * 100) + "%.");
		
		System.out.println(xserve.built + " " + xserve.make + " " + xserve.model + 
						   " runs at " + xserve.speed + "ghz and is " + 
						   xserve.getRackHeight() + "U tall.");

		showRunningMachines();

		System.out.println("\nUh oh, MacBook Air's battery is dying..");
		macBookAir.setBattery(0.0);
		
		showRunningMachines();

	}

}
