Question: In JAVA SmartPhone add a method public String getTeleponeNeighbor ( ) To calculate the telephone neighbor of any phone number, take the phone number and
In JAVA SmartPhone add a method
public String getTeleponeNeighbor
To calculate the "telephone neighbor" of any phone number, take the phone number and add one. For example, becomes
Test Case
Name: Allan Hancock College Phone:
Area code:
Prefix:
Line number:
Email: hello@hancockcollege.edu
Telephone neighbor:
Name: InNOut Burger Phone:
Area code:
Prefix:
Line number:
Email: null
Telephone neighbor:
Name: Costco Wholesale Phone:
Area code:
Prefix:
Line number:
Email: example@costcocom
Telephone neighbor:
Name: Example Phone:
Area code:
Prefix:
Line number:
Email: null
Telephone neighbor:
Name: Example Phone:
Area code:
Prefix:
Line number:
Email: null
Telephone neighbor:
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";
Phone p new SmartPhoneExample L;
Phone p new SmartPhoneExample L;
System.out.printlnp;
testp;
System.out.printlnp;
testp;
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.printlnTelephone neighbor: spgetTeleponeNeighbor;
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
