Practice reading and applying the API documentation, writing Javadocs, and developing using unit tests.
In Eclipse, checkout the JavadocsAndUnitTesting project.
SVN Repositories
view to check out this project. MoreWordGames
class.
MoreWordGames
.
MoreWordGamesTest
.
shout
, whisper
, and holleWerld
.
MoreWordGames
. Use the Java String
API documentation to look for helpful methods. For each method below you must:
MoreWordGames.java
,
MoreWordGamesTest
,
main
to call the method and print the results.
String doubleSpeak(String input)
: This method returns two copies of the input string, separated by a space. For example:
"moo"
, the output would be "moo moo"
"My cow is purple"
, the output would be "My cow is purple My cow is purple"
""
(the empty String), the output would be " "
(a single space) 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:
banana
, the output would be anaban
My cow is purple
, the output would be s purpleMy cow i
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.) For example:
1234567
, the output can be either 4567123
or 5671234
,
whichever you choose to implement.
Remember, in all your code:
Here is the grading rubric for this assignment. |
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()
):
Turn-in your programming work by committing it to your SVN repository. Bring your paper problems to class.