Lab #4

Description:

Code:

Mobile Package

package lab4;

public abstract class MobileDevice {
	private String deviceType = "MobileDevice";

	public static void main(String[] args) {
	}

	public abstract void setDeviceType();

	public String getDeviceType() {
		return this.deviceType;

	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return super.toString();
	}
}

Smartphone

package lab4;

public class SmartPhone extends MobileDevice {

	private String SmartPhone = "SmartPhone";

	@Override
	public void setDeviceType() {
		// TODO Auto-generated method stub
		this.SmartPhone = "SmartPhone";
	}

	@Override
	public String getDeviceType() {
		// TODO Auto-generated method stub
		return this.SmartPhone;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.SmartPhone; 
	}

}

Android

package lab4;

public class Android extends SmartPhone {
	@Override
	public void setDeviceType() {
		// TODO Auto-generated method stub
		this.Android = "Android";

	}

	@Override
	public String getDeviceType() {
		// TODO Auto-generated method stub
		return this.Android;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.Android;
	}
	private String Android = "Android";

}

Iphone

package lab4;

public class iPhone extends SmartPhone {
	@Override
	public void setDeviceType() {
		// TODO Auto-generated method stub
		this.iPhone = "iPhone";

	}

	@Override
	public String getDeviceType() {
		// TODO Auto-generated method stub
		return this.iPhone;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.iPhone;
	}
	private String iPhone = "iPhone";

}

Windows

package lab4;

public class WindowsPhone extends SmartPhone {
	@Override
	public void setDeviceType() {
		// TODO Auto-generated method stub
		this.WindowsPhone = "WindowsPhone";

	}

	@Override
	public String getDeviceType() {
		// TODO Auto-generated method stub
		return this.WindowsPhone;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.WindowsPhone;
	}
	private String WindowsPhone = "WindowsPhone";

}

Screenshot: