Page 1 of 1

Perhaps she'll die. CS& 141, Spring 2022 Programming Project #1: Song / Doodle (12 points) Due Wednesday, April 13th, 20

Posted: Wed Apr 27, 2022 3:29 pm
by answerhappygod
Perhaps She Ll Die Cs 141 Spring 2022 Programming Project 1 Song Doodle 12 Points Due Wednesday April 13th 20 1
Perhaps She Ll Die Cs 141 Spring 2022 Programming Project 1 Song Doodle 12 Points Due Wednesday April 13th 20 1 (290.81 KiB) Viewed 42 times
Perhaps She Ll Die Cs 141 Spring 2022 Programming Project 1 Song Doodle 12 Points Due Wednesday April 13th 20 2
Perhaps She Ll Die Cs 141 Spring 2022 Programming Project 1 Song Doodle 12 Points Due Wednesday April 13th 20 2 (276.7 KiB) Viewed 42 times
Perhaps she'll die. CS& 141, Spring 2022 Programming Project #1: Song / Doodle (12 points) Due Wednesday, April 13th, 2022, 11:59 PM Program Description: This assignment tests your understanding of static methods, println statements and basic graphics. Turn in Java files named Song.java and Doodle.java. (Use exactly these file names, including identical capitaliza- tion.) To compile and run the graphics part of this assignment, you must download the file DrawingPanel.java from the Project section of the class webpage and save it in the same folder as your code. Do not turn in Draw- ingPanel.java. Part A: Song (10 points) For Part A, you will write a program that outputs the cumulative song below, "There Was An Old Lady Who Swallowed A Fly." A cumulative song is one where each verse builds upon previous verses. Examples of other well-known cumulative songs are "The House That Jack Built" and "The Twelve Days of Christmas." The verses printed by your program must exactly re- There was an old woman who swallowed a fly. produce the output at left. This includes identical I don't know why she swallowed that fly, wording, spelling, spacing, punctuation, and capitaliza- tion. There was an old woman who swallowed a spider, That wriggled and iggled and jiggled inside her. However, the sixth verse of your song (the bold part She swallowed the spider to catch the fly, enclosed in « ») should print your own original I don't know why she swallowed that fly, Perhaps she'll die. text. Creative verses submitted may be shown in class anonymously at a later date. The only restrictions on There was an old woman who swallowed a bird, How absurd to swallow a bird. your custom verse are the following: She swallowed the bird to catch the spider, The verse must be in the same pattern as the first She swallowed the spider to catch the fly, I don't know why she swallowed that fly, five verses. For example, some versions of the Perhaps she'll die. song have a sixth verse for swallowing a goat There was an old woman who swallowed a cat, ("Just opened her throat to swallow a goat"). No- Imagine that to swallow a cat. tice that the first two lines should either end in She swallowed the cat to catch the bird, the same word (fly/fly, bird/bird, cat/cat, etc) or She swallowed the bird to catch the spider, She swallowed the spider to catch the fly, should end with rhyming words (spider/inside I don't know why she swallowed that fly, her). Perhaps she'll die. The verse must not be identical to another verse, There was an old woman who swallowed a dog, consist entirely of text from earlier in the song or What a hog to swallow a dog. She swallowed the dog to catch the cat, be a verse you'll commonly find on the web (e.g., She swallowed the cat to catch the bird, goat and cow). She swallowed the bird to catch the spider, She swallowed the spider to catch the fly, • The text of the verse should not include hateful, I don't know why she swallowed that fly, offensive, or otherwise inappropriate speech. Perhaps she'll die. << Your custom sixth verse goes here >> • The code to produce the verse is still subject to the style guidelines on the next page. There was an old woman who swallowed a horse, She died of course. One way to write this program would be to simply write a series of printin statements that output each line of the song in order. But such a solution would not receive full credit. Part of the challenge of this assign- ment lies in recognizing the structure and redundancy of the song and improving the code using static methods. 1 of 2
Style Guidelines: You may not place any println statements in your main method. (It is okay for main to have empty printin statements to print blank lines.) Instead of printing in main, use static methods for two reasons: 1. Structure You should write static methods to capture the structure of the song. You should, for example, have a method for each of the verses of the song (including your custom verse) to print that verse's entire contents. 2. Eliminating redundancy You should use only one printin statement for each distinct line of the song other than blank lines). For ex- ample, the following line appears several times in the output, but you should have only one println statement in your program that prints that line of the song: Perhaps she'll die. A method that prints just one line is not good style. Instead, identify groups of lines that appear in multiple places in the song and create methods to represent those groups. There is a general cumulative structural re- dundancy to the song that you should eliminate with your methods. Recall that methods can call other methods if necessary (which can themselves call other methods, and so on). The key question to ask is whether you have repeated lines or groups of lines of code that could be eliminated if you structured your methods differently. This includes sequences of println statements and also repeated sequences of method calls. You do not have to eliminate partial-line redundancy in lines that are similar but not identical, such as the lines that start with "There was an old woman who swallowed a." Include a comment at the beginning of your program with some basic information and a description of the pro- gram in your own words. For example: // Suzy Student, CSE 142, Autumn 2049, Section xx // Programming Assignment #1, 06/07/49 // This program's behavior is ... For this assignment, you must limit yourself to the Java features covered in the first two lectures. Though we will cover more material while you work on this assignment, please do not use any of it in this program, such as mathematical expressions, print statements (as opposed to printin), or for loops. Part B: Doodle (2 points): For the first part of this assignment, turn in a file Doodle.java that draws a figure using the DrawingPanel provided in class. You may draw any figure you like that is at least 100 x 100 pixels, contains at least three shapes, uses at least two distinct colors, is your own work. Your program also should not have any infinite loops and should not read any user input. Your score for Part B will be based solely on external correctness as just defined; it will not be graded on internal correctness. Submission and Grading: Turn in your Java source code files electronically from the Project page of the course web site. Part of your Song program's score will come from its "external correctness." External correctness measures whether the output matches exactly what is expected. We are very picky about the output matching exactly and expect every character and space to match. Use the output comparison tool to help you make sure your output for Part A is perfect. Programs that do not compile will receive no external correctness points. The rest of your Song program's score will come from its "internal correctness." Internal correctness measures whether your source code follows the stylistic guidelines specified in this document. This includes having an adequate comment header and capturing the structure and redundancy of the song as specified previously. You should also limit the lengths of all lines in your program to fewer than 100 characters. 2 of 2