Lab 4

Description:

For our fourth lab, we had to make a hierarchy that shows what type phones are grouped under. For example, all phones are under mobile devices. And a type of mobile device is smart phone. Under smart phone there are Android, iPhone, and Windows Phone.

Code:

package lab4;

public class MobileDeviceClient {	
	public static void main(String[] args) {
		MobileDevice myMobileDevice = new MobileDevice();
		SmartPhone mySmartPhone = new SmartPhone();
		iPhone myiPhone = new iPhone();
		Android myAndroid = new Android();
		WindowsPhone myWindowsPhone = new WindowsPhone();
		System.out.println(myMobileDevice.getDeviceType());
		System.out.println(mySmartPhone.getDeviceType());
		System.out.println(myiPhone.getDeviceType());		
		System.out.println(myAndroid.getDeviceType());
		System.out.println(myWindowsPhone.getDeviceType());
	}
}

package lab4;

public class MobileDevice {

	private String deviceType = "Mobile Device";
	public void setDeviceType() {}
	public String getDeviceType() 
	{
		return this.deviceType;
	}

}

package lab4;

public class SmartPhone extends MobileDevice {

	private String SmartPhone = "Mobile Device -> Smart Phone";
	
	@Override
	public void setDeviceType() 
	{
		this.SmartPhone = "SmartPhone";
	}

	@Override
	public String getDeviceType()
	{
		return this.SmartPhone;
	}

}

package lab4;

public class Android extends SmartPhone {

	private String Android = "Mobile Device -> Smart Phone -> Android";
	
	@Override
	public void setDeviceType()
	{
		this.Android = "Andriod";
	}
	
	@Override
	public String getDeviceType() 
	{
		return this.Android;
	}

}

package lab4;

public class iPhone extends SmartPhone {

	private String iPhone = "Mobile Device -> Smart Phone -> iPhone";
	
	@Override
	public void setDeviceType() 
	{
		this.iPhone = "iPhone";
	}
	
	@Override
	public String getDeviceType() 
	{
		return this.iPhone;
	}

}

package lab4;

public class WindowsPhone extends SmartPhone {

	private String WindowsPhone = "Mobile Device -> Smart Phone -> WindowsPhone";
	
	@Override
	public void setDeviceType() 
	{
		this.WindowsPhone = "WindowsPhone";
	}
	
	@Override
	public String getDeviceType() 
	{
		return this.WindowsPhone;
	}

}

Screenshot:

PICTURE OF MY PROGRAM RUNNING HERE