In this lab we create several classes describing mobile devices types. the first class was a private string . The second class is an inherit the first class which is Mobile device. then we had to create three more classes that will inherit the second class. this lab was a bit challenging but with the help of my group we were able to figure it out and get the program to run.
package edu.cuny.citytech.CET3640.Lab3; public class MobileDevice extends Object { private String deviceType; public MobileDevice() { deviceType = "Mobile Device"; } public void setDeviceType(String deviceType) { this.deviceType = deviceType; } public String getDeviceType() { return deviceType; } } package edu.cuny.citytech.CET3640.Lab3; public class SmartPhone extends MobileDevice { private String deviceType; public SmartPhone() { deviceType = "Smart Phone"; } public String getDeviceType() { return String.format("Mobile Device" + " -----> " + deviceType); } } package edu.cuny.citytech.CET3640.Lab3; public class iPhone extends SmartPhone { private String deviceType; public iPhone() { deviceType = "iPhone"; } public String getDeviceType() { return String.format("Mobile Device" + " -----> " + "Smart Phone" + " -----> " + deviceType); } } package edu.cuny.citytech.CET3640.Lab3; public class Android extends SmartPhone{ private String deviceType; public Android() { deviceType = "Android"; } public String getDeviceType() { return String.format("Mobile Device" + " -----> " + "Smart Phone" + " -----> " + deviceType); } } package edu.cuny.citytech.CET3640.Lab3; public class WindowsPhone extends SmartPhone { private String deviceType; public WindowsPhone() { deviceType = "Windows Phone"; } public String getDeviceType() { return String.format("Mobile Device" + " -----> " + "Smart Phone" + " -----> " + deviceType); } } package edu.cuny.citytech.CET3640.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()); } }