Practice reading and applying the API documentation, writing Javadocs, and developing using unit tests.
Your programming work for this assignment must be done in the
JavadocsAndUnitTesting
project inside Eclipse. Use Eclipse's
SVN Repository Exploring
perspective (or the Repository view) to check out this project, then switch back to the
Java
perspective.
MoreWordGames
class.
MoreWordGames
.
MoreWordGamesTest
.
shout
,
whisper
, and
holleWerld
.
Use the existing Unit tests in the project as
examples.
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
a string consisting of 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.)
(6) I have provided the outline of a simple Java class called Static Functions that has stubs for the following two static methods. Note that each method must return a value. Neither method should print anything. I have also provided another class that contains Unit tests to test the two methods once you have written them.
public static int maxOfThree (int a, int b,
int c)
public static int monthsToReach(double target,
double monthlyDeposit, double annualInterestRate)
A savings account starts with a zero balance on the first day of one month. On the first day of each subsequent month, interest is calculated on the current balance and added to the account, based on 1/12 of the annual interest rate. Then monthlyDeposit is added to the account. This continues each month until the first month in which the balance reaches or goes beyond target. This method returns the number of the months it takes for the balance to equal or exceed the value of target.
For example, the call monthsToReach
(30000, 500, 0.05)
represents a monthly
deposit of $500 and an annual interest rate of 5%,
asking how long it will take to accumulate $30,000.00.
The method returns 54 in this case (recall that it does
not print anything). The simpler unit tests I provided
should also help your understanding of how the
parameters are used.
(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()
):
We will grade your Wiki contributions using ANGEL. Turn-in your programming work by committing it to your SVN repository by 8:05 on the day of Session 4. Bring your answer to the written problem to the Session 4 class.