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 Parser
This 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 Sentence
NEW 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.
Modifications
DO NOT ATTEMPT until you have the first part working
Modifications Part 2
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 file
Add a new class to this project FileReader
This modification will allow a text file to be read from the computer and parsed.