Overall Requirements
Every phone number is broken up into sections as shown below:
Country Code Area Code Prefix Line Number
1 919 882 5000
Write a program to separate out a phone number when it is given with colon’s separating the sections.
[login to view URL]
Your driver class should contain the following main method: (add comments)
public static void main(String[] args)
{
RWDissector phone = new YIDissector("1:919:882:5000");
[login to view URL]([login to view URL]());
[login to view URL]([login to view URL](4));
[login to view URL]([login to view URL](1));
[login to view URL]([login to view URL](3));
[login to view URL]([login to view URL](2));
} // end main
[login to view URL]
Implement a [login to view URL] class that stores the phone number as a colon separated string of numbers and as four separate pieces described below.
You must implement all of the following:
Instance variables: (10%)
colonSeparated – a colon separated String. Example value: "1:919:882:5000"
countryCode – stored as a String as it could hold 001
areaCode, prefix, number – stored as int variables
Constructor: (30%)
This constructor receives one parameter, a colon-separated string. You may assume that the parameter’s value is valid (i.e., no error checking required). The constructor initializes the instance variables with appropriate values. There are many ways to solve the problem of extracting the sections from the given colon separated string. You are required to use String methods to extract the individual sections as strings, and then use parseInt method calls to convert the strings to int’s for those that need it. Do NOT use split as it has not been covered yet.
getPhoneNumber method with no arguments: (10%)
This is a standard accessor method that simply returns the colonSeparated instance variable’s value.
getPhoneNumber method with integer argument: (20%)
This method receives the position of one of the section (1, 2, 3, or 4) and returns the section that’s at that position. Area Code is 1, etc.
Sample Session:
When using the main method specified above, your output should be:
1:919:882:5000
5000
1
882
919
Hi there,
I am Software Engineer working for HSBC since 2 years and I have 2+ years of experience in Java programming and I can provide you this class.
And not only will just provide you the program but also will explain you in understanding the program written and also will assist you in enhancing your Java programming skills.
Lets get started.
Thanks & regards,
Webmaniac.