Intro to Programming, JAVA Programming

Assignment Help:
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.
YourNameProg1.java
Your driver class should contain the following main method: (add comments)
public static void main(String[] args)
{
YIDissector phone = new YIDissector("1:919:882:5000");
System.out.println(phone.getPhoneNumber());
System.out.println(phone.getPhoneNumber(4));
System.out.println(phone.getPhoneNumber(1));
System.out.println(phone.getPhoneNumber(3));
System.out.println(phone.getPhoneNumber(2));
} // end main
YourInitialsDissector.java
Implement a YourInitialsDissector.java 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:

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: 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:
This is a standard accessor method that simply returns the colonSeparated instance variable’s value.

getPhoneNumber method with integer argument:
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


Related Discussions:- Intro to Programming

Universal android and ios, Universal Android and iOS, Multipurpose Testing ...

Universal Android and iOS, Multipurpose Testing Application - Based on Phonegap Project Description: Universal Android and iOS, Multipurpose Testing Application Based on Phon

Write a program in javascript that will read in an xml file, Write a progra...

Write a program in Javascript that will read in an XML file. This file will contain details of devices maintained by the IT department of an organisation including an ID number, de

Create an embedded javascript function, Given the following XHTML page: ...

Given the following XHTML page:   Create an embedded JavaScript function named getUserInfo that prompts the user with the following two questions after the XHTML page has loa

Name conflicts when importing packages, Name Conflicts when importing packa...

Name Conflicts when importing packages It is possible which you will try to import a package which contains classes in which have the similar name as a class in your own source

Explain what occur when an object is created in java, Explain what occur wh...

Explain what occur when an object is created in Java?

Java graphic application, I need to draw cars and trucks and background wit...

I need to draw cars and trucks and background with road and a house with sky. I have to use Vehicle class as a parent class. To draw pictures, i should draw fun things coming up

A service locator, J2EE prepares use of the JNDI interface to access differ...

J2EE prepares use of the JNDI interface to access different resources like JMS, JDBC, EJB etc. The client finds up for these resources through the JNDI look-up. The JNDI look like

Homework, Pick your favorite geometry formula (e.g., area of a square, peri...

Pick your favorite geometry formula (e.g., area of a square, perimeter of a triangle …) and implement it in Java. Demonstrate your code compiles and runs without issue (You can use

Decision structures, for $9.95 per month, 10 hours of access are provided.A...

for $9.95 per month, 10 hours of access are provided.Additional hours are $2.00 per hour

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd