CPSC 120 Assignment #3
Critters and Flowers

Due Friday October 12, 2007 by 4:00 p.m.

In this assignment you will create classes for two graphical objects: Critters and Flowers. These objects will be combined into a Garden scene.

Create a subdirectory of your Assignments directory named assign3 for your work.

The Critter Class

Critter.java should define a class that models a bug. A critter will be defined by the following attributes:

The Critter class should have the following methods:

Following these guidelines, critters should look something like one of these three examples:

The Flower Class

Flower.java defines a class that models a flower. A flower is specified as follows:

Critters sitting in the Garden

To create the garden you need both a panel class (GardenPanel.java) and an application with a main method (GardenApp.java).

GardenPanel.java should create a custom panel that can be used for displaying your critters (model your panel after the Splat panel from p187, or one of the panels from lab5). The panel will display at least two flowers of different colors and sizes and three critters - two "parents" and one "child." The child's attributes will be an average of the two parents. So, the constructor for the panel should do the following:

The paintComponent method should call draw methods in the classes to draw the critters and flowers. Use the drawString method to label the child critter so it is clear which one is the child. Also write your name in a corner of the garden scene.

GardenApp.java is an application that puts the GardenPanel into a Frame and displays it. It should be modelled after Splat.java (p186) or one of the applications from lab5.

Suggestions for Doing the Assignment You should do the assignment in parts, getting each part right before going to the next. You should not do this all at once!! A suggested order is as follows:

Grading Notes

Your project will be graded on style, documentation and correctness. Some stylistic aspects you should pay attention to include the use of constants (where appropriate), identifier names, and the use of whitespace and proper formatting. You should also make sure that your submission does not contain uneccessary code, e.g. extra assignments or lines of code that have been commented out. Twenty percent of the final assignment grade will be for style and documentation. Documentation is a critical portion of any computer program. Each method is expected to have an overall description as well as a description of each parameter and the return value - use javadoc style documentation as we did in lab (use Eclipse to help you!). Larger methods should be internally documented with descriptions of the major steps. The balance of the grade will come from correctness, which includes meeting all of the specifications of the assignment.

Turn in

A printed copy of your program files (the Java files - Critter.java, Flower.java, GardenPanel.java, GardenApp.java). Tar all the files in your assign3 subdirectory and email the .tgz file to your instructor with a subject of cpsc120 assign3.

Academic Integrity Reminder: Assignments are to be done on your own. You may get help on the specifices of the assignment from no one but the instructor. You may not show your program to anyone else or look at anyone else's program or share ideas about how to write the program.