CS 106A | Assignment 3 Toggle navigation CS 106A Lectures Week 1 1 - Welcome to CS 106A 2 - Programming with Karel 3 - Problem-solving with Karel 4 - Introduction to Java Week 2 5 - Booleans and Control Flow 6 - Scope and Parameters 7 - Parameters and Return Week 3 8 - Characters and Strings 9 - Problem-Solving with Strings 10 - File Reading 11 - Graphics Week 4 12 - More Graphics 13 - Animation 14 - Events 15 - Events and Memory Week 5 16 - Arrays 17 - 2D Arrays 18 - More Arrays Week 6 19 - ArrayLists 20 - ArrayLists and HashMaps 21 - Classes 22 - More Classes Week 7 23 - Interactors and GCanvas 24 - GCanvas and BiasBars 25 - Life After CS106A, Part 1 26 - Life After CS106A, Part 2 Week 8 27 - Final Exam Review 1 28 - Final Exam Review 2 / Wrap-up Lecture Assignments Give Feedback Handouts 1 - General Information 1B - SCPD Information 2 - Honor Code 3 - Programming with Karel 4 - Debugging with Karel 5 - JAR Files Assignments 1 - Karel the Robot 2 - Intro to Java 3 - Snowman 4 - Breakout 5 - ImageShop 6 - BiasBars Style Guide Section Section 1 Handout Solutions Code Section 2 Handout Solutions Code Section 3 Handout Solutions Code Section 4 Handout Solutions Code Section 5 Handout Solutions Code Section 6 Handout Solutions Code Section 7 Handout Solutions Code View My Section List of all section times/locations Drop Section Schedule Assignment 3: Snowman Due: Thursday, July 19th, 11AM PST YEAH Hours: Friday, July 13th, 1:30-2:20PM (Gates B01) May be done in pairs Your third assignment is a Snowman game (based on the old "Hangman" game) that will give you practice with methods, strings and file-reading. Getting Started There is a starter project including all necessary files that you can access using the link below. Once you have the starter code set up, edit Snowman.java so that the assignment actually does what it’s supposed to do (see the assignment handout), which will involve a cycle of coding, testing, and debugging until everything works. The final step is to submit your assignment. This assignment may (optionally) be done in pairs. As a reminder, you may only pair up with others with the same section time and location. Note: You may only use concepts covered up through lecture on Wednesday, July 11 to solve these problems. In particular, you may not use Java concepts you may have learned previously such as private instance variables, arrays, etc. However, you may use concepts we cover over the next week about graphics for any optional extensions if you would like. If you have any questions about what is ok/not ok to use, please feel free to ask. Assignment Files Handout Starter Code Output Files If you would like to view them separately, the output files, which are already included in the starter code in the output folder, are listed below as well for each task specified in the assignment handout. Task 1 (Single Game) test #1 test #2 Task 2 (Single Game w/ ASCII Art) test #1 test #2 Task 3 (Random Words From Files) test #1 test #2 test #3 Task 4 (Multiple Games and Statistics) test #1 test #2 Other Resources Note: the "Debugging with Karel" handout still provides valuable debugging tips for Java programs! In particular, the debugger functions identically for Karel and Java programs. YEAH slides Style Guide Debugging with Karel The Honor Code F.A.Q. Q: I am trying to add sounds to my program, but I am getting an error that "AudioClip cannot be resolved to a type", even though I imported acm.util.* as the handout mentions. What is going on? A: You must also import java.applet.*; the handout has been updated to reflect this. Q: Is there a way to read a single character of text from the user as a char? A: You cannot read a single char. Instead, read an entire line as a String and do string processing if you would like the first character. Q: Do I have to handle the case where the user types a blank line (empty string)? A: Yes; treat this as an invalid guess. Q: I am using the promptUserForFile method to ask the user for a file name. No matter what file name I type, it never stops re-prompting me to enter the file name again and again. What is wrong? A: There can be several reasons for this, but the most common is that you are not running your project in the required way. You must use the black "running person" icon from the toolbar or the "Run" option from the Stanford Menu, not the green "Play" button. See the Eclipse guide for more information. Q: Since the program is so random, how can I possibly match the expected output? How can I use the Output Comparison Tool? A: For starters, we suggest that you match the output from the early stages of the program where the secret word is fixed at "PROGRAMMER". If your program works perfectly for those cases, it is very likely that the output is correct for others. For later phases, you don't have to match the randomly chosen words shown in our output logs. But you should have the same general output format as our logs. You can hardcode one of the words shown in the sample output to check if that part of the output is correct. Q: I'm having trouble getting Eclipse to work! Help! A: Please make sure you followed the instructions in our Eclipse Guide above. If you are still having trouble, please come to Colin or Annie's office hours, or stop by the LaIR. Q: Eclipse is giving me a strange message about a file being "out of sync" with the file system. It says I can press F5 to refresh the file. What does this mean? A: This happens if you edit/change your file outside of Eclipse. Just press F5 and Eclipse will show you the newest version of the file. Q: I didn't like the program name, such as Snowman, so I renamed it to my own name such as DaveIsGreat. That is okay, right? A: No. For grading purposes, we need you to leave the program names the way we named them. Q: How do I turn in the assignment? How do I know if my submission was successful? A: Please see the Eclipse Guide link above for more information about submitting. Q: Why doesn't my Java program say "[completed]" in the top status bar when it is done? A: This is often because your program contains an infinite loop. Make sure all of your loops are terminating properly when your program is finished! Also see the debugging handout above for how to use the Eclipse debugger to track down and squash bugs. Q: Will my solution get full credit? Is it written in the style you want? Will I get marked off for this code? A: In general we cannot answer these kinds of questions. We call this "pre-grading." The section leader/TA/instructor can't look over your entire program for mistakes or tell you exactly what things you will get marked off for; we don't have the resources to provide such a service, and even if we did, we want you to learn how to gain these intuitions on your own. We'll grade you on the guidelines in the homework document and style guide, and we can help you with specific issues and questions about your code, but we cannot pre-evaluate your entire program for you or give you advance warning about every possible mistake or violation. © Stanford 2018 | Created by Chris Piech, Nick Troccoli, and Colin Kincaid. CS 106A has been developed over time by many talented teachers.