Part 2. I will include a text file with this assignment. It is a text version of
ID: 3846997 • Letter: P
Question
Part 2.
I will include a text file with this assignment. It is a text version of this assignment.
Write a program that will read the file line by line, and break each line into an array of words using the tokenize method in the String class. Count how many words are in the file and print out that number.
Part 3.
Programming with String obejcts. Create a class to deal with telephone numbers that your customers enter. User’s aren’t very disciplined, so even if you indicate that you want the number entered like this: 407 582 2213
They sometimes enter the number like any of these: (407)582-2213 1 (407) 582-2213 407.582.2213 4075822213 1 407 582-2213 Or other combinations that I can’t think of, but they will. The constructor for your class takes a String as its only parameter.
If the number they pass to your constructor does not have 10 digits, (or 11 digits if it starts with a 1), you should throw an Exception from the constructor. InvalidTelephoneException. It’s the Telephone constructor method that will throw this exception.
A test of your class can be though of as: try to make a phone number out of a String. Telephone phone; String testString = “407.582.2213”; try { phone = new Telephone(testString); }catch(InvalidTelephoneException ite) { Send some information to the console about why that string is not a phone number } Your class must have a getAreaCode, getExchange, getLocalNumber methods. For the example above, the area code is 407, the exchange is 582, and the local number is 2213.
Follow good practices for OO programming.
A toString method will present the number in a canonical form: (407) 582-2213 Create a test class that demonstrates that your code will work correctly for each of the documented cases above. Include all of the code, and the output from running your test class. Use JavaDoc comments to document the class. Include examples IN THE JAVADOC of what format of phone numbers will be acceptable by the class (service provider) that you have created. Include the JavaDoc that is generated by running the JavaDoc tool on your code. Paste in the web page that is created.
It might be messy - don’t try to format it in Word. There is no end to this one…. The ‘service’ that this class provides will vary in its capabilities. This is a pretty common real-world problem. As soon as you think you are done someone will want it to handle something that you didn’t think of. You are ‘done’ when your code meets the requirements that are documented, and it is demonstrated.
Text doc for part 2 COP 2805c Advanced Java Assignment 5 Strings, JavaDoc, reading text files Reading:
Chapter 9 Strings in the Liang text. You will also need to read Strings from a text file. That’s in Chapter 14, or you can Google for some examples. JavaDoc – this is the standard way of documenting your Java code. It is used by the Java SDK developers. Your documentation is actually generated by the javadoc tool that extracts the comments /** Javadoc comments here */ Here is a short video to help you start JavaDoc http://youtu.be/CfvHHmwW-BA Note: If you did not install the java Developers Kit JDK, you will not have the tools required to do this. Some of you installed the JRE, which was good enough for the tasks up to now. Look for the Javadoc.exe file on your PC. If you don’t have the JDK, go get it.