Question: show work Write a class named PhoneNumber. A PhoneNumber object represents a standard phone number, like 1230567890 Here are a few terms that you need

show work show work Write a class named PhoneNumber. A PhoneNumber object represents astandard phone number, like 1230567890 Here are a few terms that youneed to know: for the phone number 123-056-7890, the "area code" is123 , the "pr efix" is 56 , and the "line number"

Write a class named PhoneNumber. A PhoneNumber object represents a standard phone number, like 1230567890 Here are a few terms that you need to know: for the phone number 123-056-7890, the "area code" is 123 , the "pr efix" is 56 , and the "line number" is 7890. The number and type of fields are up to you. Here are three ideas; pick one of them, or use your own idea: 1. Three ints: one for the area code, one for the prefix, and one for the line number. 2. Three Strings: one for the area code, one for the prefix, and one for the line number. 3. One String to store the entire phone number. The class should provide the following constructors: - public Phonenumber(String fullNumber): Initializes a PhoneNumber object using the given String. You can assume that fullNumber is of the form "nnn-nnn-nnnn", where each n is any digit, not necessarily all the same. For example, fullNumber might be "123-056-7890". - public Phonenumber(int areacode, int prefix, int linenumber): Initializes a PhoneNumber object usin g the given ints. - public Phonenumber(Phonenumber original): A copy constructor -- initializes a new PhoneNumber object to be a copy of original. The class should provide the following methods: - public int getareacode( ): Returns the area code as an int. - public int getPrefix(): Returns the prefix as an int. - public int getLinenumber( ): Returns the line number as an int. - public string tostring( ): Returns a String of the form "nnn-nnn-nnnn"; for example, "123-056-7890". - public boolean isequalto(Phonenumber other): Determines whether this PhoneNumber and the given othe r PhoneNumber represent phone numbers that are equal. Note: You may find some of the following methods useful at certain points: - In the String class, the substring and split methods. - In the Integer class, the parselnt method. Here's an example showing how to use the split method: suppose we have string date ="20220615"; then date.split("-") gives us the array {"2022","06","15"}. Another example: suppose we have String time ="1:53:45"; then time.split(":") gives us the array {"1","53","45"}. The testing code is provided below, in TestPhoneNumber.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!