Lab 3 – MobDevice

In this lab, I created a super class “MobDevice”,
it is going to display the relationships between the phone systems, and smartphones.
The subclasses use the same method under the super class;
I used the set and get method in this case.


import java.lang.String;

public class Mob {
	
		public static void main(String args [])
		{
			MobDevice phone= new MobDevice();
			SmartPhone smart = new SmartPhone();
			Android robo = new Android();
			Iphone ios = new Iphone();
			WinPhone win = new WinPhone();

			System.out.println(phone.getDeviceType());
			System.out.println(smart.getDeviceType());
			System.out.println(robo.getDeviceType());
			System.out.println(ios.getDeviceType());
			System.out.println(win.getDeviceType());
		}
	}
===========================================================================
import java.lang.String;

public class MobDevice {
	private String deviceType = new String();

	public MobDevice(){
		setDeviceType("Mobile Device");
	}

	public String getDeviceType(){
		return deviceType;
	}

	public void setDeviceType(String str){
		deviceType = str;
	}
}
===========================================================================
public class SmartPhone extends MobDevice{
	private String deviceType = new String();
	
	public SmartPhone(){
		deviceType = "Smart Phone";
	}
	
	public String getDeviceType(){
		deviceType = super.getDeviceType() + " == "+ deviceType;
				return deviceType;
	}
}
===========================================================================
public class Android extends SmartPhone{
	private String deviceType = new String();
	
	public Android(){
		deviceType = "Android";
		
	}
	
	public String getDeviceType(){
			deviceType = super.getDeviceType() + " == " + deviceType;
		return deviceType;
	}
}
===========================================================================
public class Iphone extends SmartPhone{

	private String deviceType = new String();
	
	public Iphone(){	
		deviceType = "iphone";
		
	}
	
	public String getDeviceType(){
		deviceType = super.getDeviceType() + " == " + deviceType;
				return deviceType;
		
	}
}
============================================================================
public class WinPhone extends SmartPhone{
	private String deviceType = new String ();
	
	public WinPhone(){	
		deviceType = "Windows Phone";
	
	}
	
	public String getDeviceType(){
		deviceType = super.getDeviceType() + " == " + deviceType;
		return deviceType;
	}
}
MobDevice

Leave a Reply

Your email address will not be published. Required fields are marked *