You will need to use some the Java: Strings method to complete this assignment. To parse something is to break it down into smaller parts. For example to parse a sentence into words, you break out each word in the sentence. That is your assignment. To start, do not include punctuation in your sentence. Object #1 ParserThis object will have two methods:
Use this to strat your object: public class Parser { /** * Constructor for objects of class Parser */ public Parser() { } /** * Returns the first word of a string * * @param phrase a phrase that will used as input * @return the fisrt work in parameter phrase */ public String firstWord(String phrase) { String firstWord =""; // your code to extract the first word of the phrase goes here return firstWord; } /** * removes the first word of a string * * @param phrase a phrase that will used as input * @return the phrase less the first word */ public String removeFirstWord(String phrase) { String newPhrase =""; // your code to remove the first word of the phrase goes here return newPhrase; } } Object #2 SentenceNEW CONCEPT: parameters are passed by value, not by reference. ie. methods only use the values of parameters. The original variable value does not change (yet). This object will:
Non critical Input errors to check. These errors will be caught by your program and produce the correct results. DO NOT ATTEMPT until you have the first part working
ALSO SEE: Java: 1D Arrays DO NOT ATTEMPT until you have the above modifications working
This code will append a new word to an array: Output the all stats in the Sentence class. Read text from a fileAdd a new class to this project FileReader This modification will allow a text file to be read from the computer and parsed. |