CPSC 120B Assignment #2

Due, Friday October 11, 2002 by 4:00 p.m.

Write a Java applet that draws two critters of some sort (robots, clowns, monsters, "Big Bird"- like things -- use your imagination -- anything but snowmen). The critters must have a head, arms, legs, and a main trunk. The head should have eyes with pupils, a nose and a mouth. The size of each critter will be determined randomly -- for each, generate a random number in some range (you determine a range that gives reasonable size critters AND gives clearly distinguishable sizes) for the height of the trunk of the body. The width of the trunk and other body parts should be determined in proportion to the height (for example, you may want the head to be one-third the height or 28% of the height -- some function of the height). The coordinates of the pieces will also need to be related to the height. The feet of the two critters should be at the same level (that is, don't have one critter suspended in the air!).

Put a label "Tallest" over the tallest of the two critters and "Smallest" over the shortest of the two. If the two are exactly the same height, label them both "Even". (You may use more creative labels if you wish or draw something to designate each of the three possibilities!!)

Generate a random point (a random x and y coordinate) and draw a red dot at the point (make the dot a circle of radius at least 5). The random point should be anywhere on the applet window (that is, the x value should be a random number between 0 and the width of the applet and y should be between 0 and the height of the applet). If the dot touches the trunk of either critter make that trunk go away (that is, color the trunk the same color as the background).

Extra Credit: Make the eyes of each critter look at the dot!

Additional requirements:

Grading

Your program will be graded both on style and correctness. Style includes adherence to rules for naming of identifiers and use of white space; it also includes coding style such as the absence of unnecessary code (extra comparisons in if's or extra assignments); it includes appropriate documentation. Style will be 20% of the grade on the assignment. Correctness includes meeting all the specifications of the assignment. A program that does not compile has an automatic deduction of 70%; one that does not run has an automatic deduction of 40% no matter how "close" it is to compiling or running. Come see me if you have problems with the assignment. It is important that you get in the habit of producing correct programs!

Academic Integrity Reminder!!! Programming assignments are to be your own work. You may get help on the specifics of the assignment from no one except the instructor. You may not show your program to anyone or look at anyone else's program or share ideas with anyone about how to write the program.

Hand IN: A printed copy of your program. Tar the .class, .html, and .java files and email the .tgz file to ingram@roanoke.edu with a subject of cpsc120 project2.