[Solved]Activity Create Class Called Sentence Sentence Class Determine Phrase Substring Within Sen Q37161578
Activity:
- Create a class called Sentence
- The Sentence class will determine if a phrase (substring) iswithin a sentence object, for example “ing” is contain in thesentence “The boy is running”.
- Instance variable – String that represents a sentence.
- Constructor – single parameters that sets the instancevariable
- Methods
- Accessor and mutator for the sentence
- find method
- takes in a String parameter that represents the targetsubstring, (what we are looking)
- returns true if the substring occurs in the sentence, false ifit doesn’t occur.
- Must use recursion and use this algorithm
- If sentence starts with the target substring return true
- If not, test the rest of the sentence recursively.
- Remember to include stopping base case(s).
- Enhancement (Optional)
- create an indexOf method
- takes in a String parameter that represents the targetsubstring, (what we are looking)
- returns the index in the Sentence of the first occurence of thetarget substring or -1 if not found
- Must use recursion
- One approach is to use a recursive helper method
- The purpose of a “helper” recursive methods is, in general, tohide the counting of something. They usually have (at least) oneadditional parameter that somehow describes how far the recursionhas already proceeded or how far it still has to proceed. In ourcase the helper method extra parameter would be where the newstring starts, and that parameter would be returned when thesubstring is found.
- create an indexOf method
- Create a SentenceTester class
- Create a Sentence object.
- Test several phrase including several with match throughout thesentence and some that do not match.
- Remember to include javadoc for the Sentence class.
Expert Answer
Answer to Activity: Create a class called Sentence The Sentence class will determine if a phrase (substring) is within a sentence … . . .
OR

