Intro to Programming, JAVA Programming

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

Posted Date: 10/23/2012 6:34:52 AM | Location : United States







Related Discussions:- Intro to Programming, Assignment Help, Ask Question on Intro to Programming, Get Answer, Expert's Help, Intro to Programming Discussions

Write discussion on Intro to Programming
Your posts are moderated
Related Questions
Viewing a User's Wall Where your project allows you to view a user's profile, your ZHTML must provide the following capabilities: 1. Provide a Wall for that user profile, dis

write code employe managment

Two XML configuration files are uses by The Validator Framework validator-rules.xml and validation.xml. The validator-rules.xml shows the standard validation routines, these are re

Describe Graphics Objects ? In Java all drawing takes place via a Graphics object. This is an example of the class java.awt.Graphics. Initially the Graphics object you use w

15. Energy Drink Consumption A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchase one or more energy dr

The hashCode() and equals() methods have to be very important, when objects implementing these two functions are added to collections. If not implemented or implemented incorre

Develop a desktop Chatbot application Project Description: Looking for an in depth and smart working chatbot Seeking someone with skills working with AI and chatbots and t

Specifications 1. readNumberOfEntries → This function will ask the user for a value greater than or equal to two. The function will keep asking values as long as the user prov

YES. JSP technology is extensible by the development of custom actions, or tags, which are encapsulated in tag libraries. #question..

Project Description: The program must work on all realms, all ladders, all cores (4x realms,2x ladders,2x cores) The program must be unpatchable and undetectable If patche