Computer Science 120
Introduction to Programming

Spring 2012, Siena College

Lab 5: Snowmen
Due: the start of your next lab session

This week's hopefully-brief lab assignment involves the creation and use of a class to represent a snowman. We haven't seen many of those in this nonexistent winter, so here's your chance to have some fun with the snow. While this lab is not due until your next actual lab meeting (in 2 weeks), you are strongly encouraged to complete the program before the exam, as it will serve as good review.

When you run your program, a mouse click should create a snowman. If the click is on the most recently-created snowman, the snowman will instead change a bit. Details below.

You may work alone or with a partner on this lab.

There is no formal design document to be graded this week, but you are strongly encouraged to begin, as usual, with pencil and paper sketching out a plan before you start coding.

Problem Description

The canvas may start initially empty, or you can come up with some simple "winter scene" to act as your background.

The required functionality involves the creation and manipulation of snowmen. A mouse click normally will create a snowman whose base is centered at the click point. Feel free to be creative with your snowman's design, but it should consist of at least two or three opaque snowballs, it must wear a hat, and it must have two arms that can be oriented in at least two positions each. The color of the hat should be chosen randomly (from among a fixed set of at least three colors)

If you click the mouse on the most recently-drawn snowman, one of two things should happen with equal probability: its hat should change color or one of its arms should change its orientation.

A working solution for this program will appear below. Click inside the applet to interact with it.

Your program should use two classes. You may name them as you choose, but one should be a custom class that represents a snowman and the other should be one that extends WindowController that handles mouse events.

Your snowmen should be at least as complex as those in the demo solution. But feel free to make more interesting snowmen. Up to four bonus points are available for especially elaborate snowmen.

Submitting Your Work

Before the start of your next lab session, submit your Java program for grading. There are three things you need to do to complete the submission: (i) place a copy of your Java program into your csis120/hw folder under hw8, (ii) print a copy of your program and hand it to your instructor, and (iii) demonstrate the execution of your program for your instructor.

Don't forget to check your programs for compliance with the Style Guide for CSIS 120 Programs


This assignment is worth 100 points, which are distributed as follows:

> FeatureValueScore
Style, Design, and Efficiency
Appropriate comments 6
Good variable names 4
Appropriate variable declarations 8
Good use of constants 8
Appropriate formatting 2
Does not generate new objects unnecessarily 4
Good overall design and methods 8
Basic snowman drawing 15
Initial hat color random from a fixed set of colors 6
At least two possible positions for each arm 6
Initial arm positions randomly chosen 5
New snowman on click outside most-recent snowman 5
Most recent snowman modified when clicked on 6
Randomization between hat color change and arm orientation 5
If hat color change, randomly choose a new color 6
If arm orientation change, randomly choose which arm to change 6
Extra Credit
Fancy snowmen 4
Total 100