Quiz: Polish Our Code
Which methods should we remove or generalize, and which should we keep?
- Remove or generalize|Keep
public int occurrencesOf(String word) -
Remove or generalize|Keep
public int occurrencesOfAlice()You don't want a method to search for a specific word when you can have one that searches for any word. -
Remove or generalize|Keep
public int getFirstSentence() -
Remove or generalize|Keep
public int getSecondSentence()It would make sense to generalize to a method that gets the nth sentence for an arbitrary n. But that's not what Sara is planning to do, because we haven't yet learned how to do it. Don't worry if you said “Remove or generalize” here. -
Remove or generalize|Keep
public int getNumCharacters() -
Remove or generalize|Keep
public int firstOccurrenceOfMadHatter()It would be better to have a method that finds the first occurrence of any word. -
Remove or generalize|Keep
public void readBook(String fileName)