Discription
This lab was completely different than I thought. I had serveral ideas on how to do em in which got me no where. with the help of my group, I was about to fix everything wrong with my program and next they helped me understand how to start it. this lab really took me a very long time to figure out and with the help of my classmate I was able to understand and finish the lab.
Program
package lab3; public class Android extends SmartPhone { private String deviceType; public Android() { deviceType = "Android"; } @Override public String getDeviceType() { deviceType = super.getDeviceType() + " --> " + deviceType; return deviceType; } }
package lab3; public class iPhone extends SmartPhone { private String deviceType; public iPhone() { deviceType = "iPhone"; } @Override public String getDeviceType() { deviceType = super.getDeviceType() + " --> " + deviceType; return deviceType; } }
package lab3; public class MobileDevice { private String deviceType; public MobileDevice(){ deviceType = "Mobile Device"; } public String getDeviceType(){ return this.deviceType; } }
package lab3; 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 lab3; public class SmartPhone extends MobileDevice { private String deviceType; public SmartPhone() { deviceType = "Smart Phone"; } @Override public String getDeviceType() { deviceType = super.getDeviceType() + " --> " + deviceType; return deviceType; } }
package lab3; public class WindowsPhone extends SmartPhone { private String deviceType; public WindowsPhone() { deviceType = "WindowsPhone"; } @Override public String getDeviceType() { deviceType = super.getDeviceType() + " --> " + deviceType; return deviceType; } }
Screen Shot