CSSE 220 – Object-Oriented Software Development

Homework 3

Objectives

Practice reading and applying the API documentation, writing Javadocs, and developing using unit tests.

Tasks

  1. Complete the assigned reading for the next session: read Big Java §2.11–2.13. The second paragraph of §2.11 says that the material is optional. It is not optional if you plan to successfully complete the course. (The course schedule will list the reading to be completed before each session.) As you read, see if you can answer the self-check questions. If there is something you do not understand, make note of it so you can ask about it.
  2. Edit the Big Java Review Wiki on ANGEL, adding answers to two of the review exercises from chapter 2. Be sure to carefully follow the instructions for doing this that are posted on the Wiki.
  3. Programming:
    1. Your programming work for this assignment must be done in the JavadocsAndUnitTesting project inside Eclipse. Use the SVN Repository Exploring perspective to check out this project, then switch back to the Java perspective.

    2. We completed this step in class. Add appropriate Javadoc comments to the MoreWordGames class.
    3. We completed this step in class. Create a JUnit 4 Test Case for MoreWordGames.
      • Name your test case class MoreWordGamesTest.
      • Write unit tests for shout, whisper, and holleWerld.
      • Remember, the goal is to write tests that cover “interesting” cases.
    4. Below are the specifications for two additional methods that you will add to MoreWordGames. Use the Java String API documentation to look for helpful methods. For each method below you must:
      1. add a documented method stub to MoreWordGames.java,
      2. add interesting unit tests to MoreWordGamesTest,
      3. implement the method, and
      4. add a line to main to call the method and print the results.
      Here are the methods that you should add:
      • String doubleSpeak(String input): This method returns two copies of the input string, separated by a space. For example, if the input were "moo", the output would be "moo moo"
      • String cartBeforeTheHorse(String input): This method returns a string consisting of the last half of the input, followed by the first half, with no intervening space. For example, if the input were banana, the output would be anaban. You can decide how to handle odd-length input, though one choice lets you avoid using an if-statement. (Recall that integer division truncates the fractional part.)
  4. Written Problem: Draw your answers to this problem neatly on paper. Clearly label each part of the problem.

    The ObjectReferenceExamples class contains several methods. For each method (except main()):

    1. Draw a box and pointer diagram, like we did in class, showing the result of running the method.
    2. Use your drawings to predict the output of the method.
    3. After you have made your predictions, run the program to check your answers.
    4. If your prediction was wrong, you may neatly line through it (and your drawing if necessary) and add the correct answer.

Turn-in Instructions

We will grade your Wiki contributions using ANGEL. Turn-in your programming work by committing it to your SVN repository.