Question: having trouble coding these methods please help, will up vote if answer is correct addWord(String) Other methods called : endsWtihPunctuation(String) This is the method that
having trouble coding these methods please help, will up vote if answer is correct
addWord(String)
Other methods called : endsWtihPunctuation(String)
This is the method that does most of the processing for this application. The first thing that is done is the previous word is checked to see if it ended with punctuation. If the previous word ended with punctuation then the current word is added under the PUNCTUATION key in the words HashMap.
If the previous word did NOT end with punctuation then the HashMap words is checked to see if the previous word has an entry in the HashMap. If the previous word is not present in the HashMap, it will need to be added.
Once the previous word is present in the HashMap the current word is added to the ArrayList that uses the previous word as a key.
endsWithPunctuation(String)
This method takes a String and checks if the last character of the String exists in PUNCTUATION_MARKS. If the last character does exist in PUNCTUATION_MARKS the method returns true, otherwise it returns false
This method should also catch any errors that may occur when checking for punctuation. If an error is caught, print the word that caused the error along with an error message. This is unlikely to occur however.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
