Lab: Words and Separators
Objective
In this lab you will implement a couple of methods that might be useful in the solution to the Glossary project.
Setup
Follow these steps to set up a project for this lab.
- Create a new Eclipse project by copying
ProjectTemplate. Name the new projectNextWordOrSeparator. - Open the
srcfolder of this project and then open(default package). As a starting point you can use any of the Java files. Rename itNextWordOrSeparatorTestand delete the other files from the project. - Follow the link to
NextWordOrSeparatorTest.java, select all the code on that page and copy it to the clipboard; then open theNextWordOrSeparatorTest.javafile in Eclipse and paste the code to replace the file contents. Save your file.
Method
- First carefully look through the
NextWordOrSeparatorTest.javafile and the main method in particular. Make sure you understand what the method does. What is the definition of "separator" characters used in the program? - Complete the given class by pasting the bodies of the
generateElementsandnextWordOrSeparatorstatic methods you wrote for the homework into theNextWordOrSeparatorTest.javafile. - Run the program and thoroughly test your implementations with a variety of different inputs involving different characters, including letters, digits, white space characters, and various punctuation characters.
Additional Activities
- Create a JUnit test fixture and provide test cases for the static methods you implemented.
- Modify the definition of "separator" characters to better match your intuition of what a word and a separator string should be. Test your modified implementation.