Work on this exercise by yourself, but be quick to ask questions of your instructor, student assistants and classmates as desired.
GoalsSolidify your understanding of how to:
|
Grading rubricEach class that you write counts 10 points:
Additionally, your score is reduced by 1/2 if your class:
Additionally, your score on the tests for a class is the minimum of the score on your tests and your score on tests that you peer-reviewed.
Finally, recall that this is a learning exercise, not a test. Hence, we will grade the “first draft” of your tests/code and then you may submit a second draft with errors corrected.
|
/** * A StringTransformable object can transform one String into another String. * * @author David Mutchler, based on an idea from Lynn Stein * in her Rethinking CS 101 project. * Created Mar 12, 2009. */ public interface StringTransformable { /** * Transform the given String into another String. * * @param stringToTransform The String to transform * @return The transformed String */ public String transform(String stringToTransform); }
Add the above StringTransformable interface to your project now.
When your class is correct, commmit your project.
Shouter:
given blah,
produces the result of changing all the characters in
blah to upper-case.
|
Censor:
given blah,
produces the result of replacing each occurrence of the character (not string)
foo in blah with an asterisk,
where foo is the character that the particular Censor censors.
|
Pedant:
puts "Obviously " before its given string.
|
NameDropper:
puts "foo says "
before its given string,
where foo is the name that the particular NameDropper drops.
|
Counter:
puts a number in front of each input, that goes 1, 2, 3, ...
For Example:
A good way to functionally test this class is to:
|
Doubler:
repeats the given string two times, with a single space in between.
|
SlowThinker:
produces whatever it was given the previous time.
For example:
As with Counter (and indeed, as with all these StringTransformers), each instance of SlowThinker is independent of other instances of SlowThinker. This one is challenging! Don't spend more than 30 minutes on its code (unless you want to!). |
SometimesShouter:
has a nonnegative whole number (I'll call it n).
The SometimesCapitalizer capitalizes every
nth String that it is given (and leaves other Strings unchanged).
Each SometimesCapitalizer has its own number (so n should be a field that can be set using a constructor. If it is not told about any such number, it will use 2 (capitalizing every other string it is given) by default. For example:
Just ask if you have questions about what a SometimesCapitalizer is supposed to do. |
Repeater:
transforms the given String into N copies of the given String,
where N is the length of the given String.
For example:
|
Evener:
transforms the given String into
a String consisting of only the characters whose positions in the given string are even.
For example:
Note that in the above definition, the first character's position is “even”, because we start numbering from 0 (as in the C language) and we consider 0 to be an “even” number. |
UbbiDubbier:
transforms the given String into Ubbi Dubbi.
|