lab #5

Description:

In this lab we follow up upon the last lab, but we modify it so that there are two different mobile device. Within the mobile device you have the choice of a Smartphone or Tablet.

Codes:

Mobile Device

package lab5
public class MobileDevice {

	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 lab5
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 lab5
public class AndroidS extends SmartPhone{

private String AndroidS = "AndroidS";

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

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

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

}

Iphone

package lab5
public class Iphone extends SmartPhone {

private String Iphone = "Iphone";

	@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 lab5
public class WindowsS extends SmartPhone {
private String WindowsS = "WindowsS";

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

	}

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

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

}

Tablet

package lab5
public class Tablet extends MobileDevice {

private String Tablet = "Tablet";

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

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

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

}

Android

package lab5
public class AndroidT extends Tablet {
private String AndroidT = "AndroidT";

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

	}

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

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

}

Ipad

package lab5
public class Ipad extends Tablet {
private String Ipad = "Ipad";

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

	}

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

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

Windows

package lab5
public class WindowsT extends Tablet {
private String WindowsT = "WindowsT";

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

	}

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

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

}

Recent Posts