Lab #4

Objective:
The goal of this lab is to create a class Called MobileDevice in this with a private field names deviceType that will be initialized to the string “Mobile Device” in the constructor. Include the corresponding setter and getter methods. And the output of this program that calls out Smartphone Device such as iPhone, Android, and WindowsPhone.

Code:

package lab4;
public class MobileDeviceClient
{
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		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";
	public void setDeviceType() 
	{
		this.SmartPhone="SmartPhone";
	}
	public String getDeviceType() 
	{
		return this.SmartPhone;
	}
}
//this code is for iPhone
package lab4;
public class iPhone extends SmartPhone 
{
	private String iPhone="Mobile Device--->Smart Phone--->iPhone";
	public void setDeviceType() 
	{
		// TODO Auto-generated method stub
		this.iPhone = "iPhone";
	}
	public String getDeviceType() 
	{
		// TODO Auto-generated method stub
		return this.iPhone;
	}
}
//this code is for the Android which extends from the Smartphone code
package lab4;
public class Android extends SmartPhone 
{
	private String Android="Mobile Device--->Smart Phone --->Android";
	public void setDeviceType() 
	{
		this.Android = "Andriod";
	}
	public String getDeviceType() 
	{
		return this.Android;
	}
}
package lab4;
public class WindowsPhone extends SmartPhone 
{
	private String WindowsPhone="Mobile Device --->Smart Phone---> WindowsPhone";
	public void setDeviceType() 
	{
		this.WindowsPhone = "WindowsPhone";
	}
	public String getDeviceType() 
	{
		return this.WindowsPhone;
	}
}

ScreenShots