lab#5

Description
FOR LAB #5 I IMPLEMENT SOME CHANGE FROM THE LAST LAB, WHO WAS ABOUT MOBILE DEVICES. IN THE PRECIOUS LAB 4 I USED 4 MOBILE DEVICES WHO WERE IPHONE, ANDROID,SMARTPHONE AND WINDOWPHONE. IN LAB 5 I DIDNT DO ANY CHANGE THE ONLY CHANGE I DID WAS JUST ADD TWO OTHER DEVICES IN ORDER OF HIERARCHY. THE IMPLEMENTATION THAT I DID WAS TO ADD TWO NEW MOBILE DEVICES WHICH WERE KINDLE FIRE AND NEXUS 7. WHEN I RUN THE PROGRAM TOGETHER WITH THE OTHER DEVICES FROM PREVIOUS LAB, I WAS ABLE TO SEE ALL THE COMPONENT LISTING TOGETHER AS ONE.

CODE
Part1 package lab4;

public class MobileDeviceApp {

public static void main(String[] args) {

MobileDevice[] mobileDevices = new MobileDevice[6];
mobileDevices[0] = new smartphone();
mobileDevices[1] = new Iphone5();
mobileDevices[2] = new androi();
mobileDevices[3] = new WindowsPhone();
mobileDevices[4] = new kindlefire();
mobileDevices[5] = new nexus7();

for (MobileDevice m: mobileDevices){
System.out.println(“This device is: ” + m.toString());
}
}

}

part 2

package lab4;

public abstract class MobileDevice {

public String deviceType = “Device Type”;

public abstract void setDeviceType();

public String getDeviceType(){
return this.deviceType;
}

public String toString(){
return this.deviceType;

}

}

Part 3

package lab4;

public class smartphone extends MobileDevice {
private String mySmartphone = “Smartphone”;

public void setDeviceType(){
this.mySmartphone = “Smartphone”;
}

public String getDeviceType(){
return this.mySmartphone;
}

public String toString(){
return this.mySmartphone;
}

}

Part 4

package lab4;

public class Iphone5 extends MobileDevice {
private String myPhone = “Iphone5”;

public void setDeviceType(){
this.myPhone = “Iphone5”;
}

public String getDeviceType(){
return this.myPhone;
}

public String toString(){
return this.myPhone;
}
}
Part 5

package lab4;

public class WindowsPhone extends MobileDevice {
private String mywindowsPhone = “windowsPhone”;

public void setDeviceType(){
this.mywindowsPhone = “windowsPhone”;
}

public String getDeviceType(){
return this.mywindowsPhone;
}

public String toString(){
return this.mywindowsPhone;
}

}

Part 6

package lab4;

public class androi extends MobileDevice {
private String myandroi = “androi”;

public void setDeviceType(){
this.myandroi = “androi”;
}

public String getDeviceType(){
return this.myandroi;
}

public String toString(){
return this.myandroi;
}

}

Part7

public class kindlefire extends MobileDevice {
private String mykindlefire = “kindletfire”;

public void setDeviceType(){
this.mykindlefire = “kindlefire”;
}

public String getDeviceType(){
return this.mykindlefire;
}

public String toString(){
return this.mykindlefire;
}
}

Part 8
package lab4;

public class nexus7 extends MobileDevice {
private String mynexus7 = “nexus7”;

public void setDeviceType(){
this.mynexus7 = “nexus7”;
}

public String getDeviceType(){
return this.mynexus7;
}

public String toString(){
return this.mynexus7;
}
}

PRINT SCREEN

code for lab5