Reference no: EM133233012
Create three classes CellPhone, FlipPhone, and SmartPhone. FlipPhone and SmartPhone should be subclasses of CellPhone.
A cell phone should have attributes for model (String), owner (String), and phone number (int). It should have a default constructor that assigns default values for these attributes.
Write methods for CellPhone named call() and hangup(). The CellPhone hangup method should print "hanging up cell phone". The CellPhone call method should print out that the owner is calling from the phone number (use the variable values for this information).
FlipPhone should override hangup() and print "close phone".
SmartPhone should also override hangup() and print "press end button". SmartPhone should also have attributes for operating system and memory size. It should have a constructor that takes in these as parameters. These variables should be named meaningfully and with reasonable types (I recommend String and int).
Complete the attached PhoneDriver class by adding at least 1 FlipPhone, 2 SmartPhone and 1 CellPhone to the phones ArrayList. (Add at owner names to at least 2 phones. At least one SmartPhone must have operating system and memory size values set.
Run PhoneDriver to see the output.
// Driver class for cell phone assignment
import java.util.ArrayList;
public class PhoneDriver{
public static void main(String[] args) {
ArrayList<CellPhone> phones = new ArrayList<CellPhone>
// add 1 FlipPhone to ArrayList
// add 2 SmartPhone to ArrayList
// add 1 CellPhone to ArrayList
for (CellPhone phone : phones ) {
phone.call();
phone.hangup();
}
}
}