TCSS 142 Assignment 1b solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (4 votes)

In the last portion of our lecture, we learn how to reduce redundancy by utilizing methods and identifying the structure of the shapes to be drawn and the redundancy within the shapes. We will use this same strategy to complete the following programming assignment. By using println statements within several methods, you are to reproduce “Exactly,” the lyrics of “There Was An Old Woman,” as seen below:
There was an old woman who swallowed a fly, I don’t know why she swallowed a fly, Perhaps she’ll die.
There was an old woman who swallowed a spider, That wriggled and jiggled and tickled inside her, She swallowed the spider to catch the fly, I don’t know why she swallowed a fly, Perhaps she’ll die.
There was an old woman who swallowed a bird, How absurd! to swallow a bird, She swallowed the bird to catch the spider, That wriggled and jiggled and tickled inside her, She swallowed the spider to catch the fly, I don’t know why she swallowed a fly, Perhaps she’ll die.
There was an old woman who swallowed a cat, Imagine that! to swallow a cat, She swallowed the cat to catch the bird, She swallowed the bird to catch the spider, That wriggled and jiggled and tickled inside her, She swallowed the spider to catch the fly, I don’t know why she swallowed a fly, Perhaps she’ll die.
There was an old woman who swallowed a dog, What a hog! to swallow a dog, She swallowed the dog to catch the cat, She swallowed the cat to catch the bird, She swallowed the bird to catch the spider, That wriggled and jiggled and tickled inside her, She swallowed the spider to catch the fly, I don’t know why she swallowed a fly, Perhaps she’ll die.
There was an old woman who swallowed a horse, She’s dead—of course!
All of the println statements should be contained in static methods. Remember, you should identify lines that are repeated and place them within a method that can be called whenever that line needs to be output. You should not type any unique line of the song as a println string more than once.
Do not concern yourself with redundancy you see in a partial line, such as: There was an old woman who swallowed a spider There was an old woman who swallowed a bird, There was an old woman who swallowed a cat, etc.
or
She swallowed the cat to catch the bird, She swallowed the bird to catch the spider
This is too complex for the tools we have learn thus far. Only deal with entire lines that are redundant. Also, your program should not use any programming techniques outside of what we have learned in chapter 1.
Our version of the song only has six verses which suggest a structure of six static methods to be called by the main method. However, to eliminate the redundancy that builds in each verse, more methods will need to be created and called from within these “verse” methods. Think about our final solution to the shapes drawn in lecture.
Your final program should include a brief documented statement to clarify each method such as:
// firstverse method outputs the fly verse public static void firstverse ( ) { etc.
You should also include documentation at the beginning to identify yourself, course, date, instructor, assignment #, and a brief description of what the program does, such as:
/************************************************ * John Depp * TCSS142 * June 27, 2013 * Mr. Schuessler * Assignment 1 * * This program outputs the lyrics to… *************************************************/
or anything that looks clear.
Save your program as Fly.java …this implies the name of your Class. Don’t forget!
Grading:
Program Compiles: 20% Correct Output: 20% Documentation (text and proper/consistent indentation): 20% Proper use of methods to reduce redundancy: 30% (remember, assignment 1a is 10%).
Good Luck and Start Early!