Question: Add another constructor to SmartPhone. Make this constructor accept a name, phone, and email. Save name and phone in the superclass and save email in
Add another constructor to SmartPhone. Make this constructor accept a name, phone, and email. Save name and phone in the superclass and save email in SmartPhone subclass
Also In SmartPhone, add the method
public String getEmail
Make this method return the email address that was passed to the constructor.
Test Case
Name: Allan Hancock College Phone:
Area code:
Prefix:
Line number:
Email: hello@hancockcollege.edu
Name: InNOut Burger Phone:
Area code:
Prefix:
Line number:
Email: null
Name: Costco Wholesale Phone:
Area code:
Prefix:
Line number:
Email: example@costcocom
public class Demo
public static void mainString args
Phone p new SmartPhoneAllan Hancock College", L "hello@hancockcollege.edu";
Phone p new SmartPhoneInNOut Burger", L;
Phone p new SmartPhoneCostco Wholesale", L "example@costcocom";
System.out.printlnp;
testp;
System.out.printlnp;
testp;
System.out.printlnp;
testp;
public static void testPhone p
this will confirm that SmartPhone is a subclass of phone
SmartPhone sp SmartPhonep;
System.out.printlnArea code: spgetAreaCode;
System.out.printlnPrefix: spgetPrefix;
System.out.printlnLine number: spgetLineNumber;
System.out.printlnEmail: spgetEmail;
System.out.println;
public class Phone
protected String name;
protected long number;
public PhoneString name, long number
this.name name;
this.number number;
public String toString
return "I am a phone!";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
