CS 305J Assignment, Problem Decomposition
| Programming Assignment 2 | Individual Assignment. You must complete this assignment by
yourself. You cannot work with anyone else in the class or with someone
outside of the class. The code your write must be your own. You are
encouraged to get help from the instructional staff. Placed online:
Wednesday, September 3 |
||||
| Description | The purposes of this assignment are:
Write a Java program that when run produces the following output (The lyrics of the song There Was an Old Woman Who Swallowed a Fly):
You must exactly reproduce the format of this output. You are to make use of static methods to avoid the “simple” redundancy. In particular, you are to make sure that you use only one println statement for each distinct line of the song. For example, this line:
appears several times in the output. You are to have only one println statement in your program for producing this line. So you may have static methods with a single println in them. The more complex redundancy has to do with pairs of lines like these:
and like these:
It is not possible to avoid this redundancy using just methods and simple println statements, so you are not expected to do so. In other words the lines
are very similar. The only difference is the last word. It is okay to have one println for the line
and another println for the line
even though it seems redundant. There is, however, a structural redundancy that you can eliminate with static methods. The key question to ask yourself is whether or not you have repeated lines of code or statements that could be eliminated if you structured your static methods differently. These lines of codes could be calls to static methods instead of println statements. Use static methods to capture the structure of the song. You should, for example, have a different method for each of the six verses of the song (verses are separated by blank lines in the output). You are not allowed to use more advanced features than what we have covered in class. For this assignment, you should limit yourself to the Java features covered in chapter 1 of the text. When finished turn in your Song.java program using the turnin program. |
||||
| Files |
|
||||
| Checklist | Did you remember to:
|
Thanks to Stuart Reges for letting me use this assignment.