CPSC 120B Assignment #2
Due, Friday October 15, 2004 by 4:00 p.m.
Write a Java applet that draws a scene containing
two critters of some sort (robots,
clowns, monsters, "Big Bird"- like things -- use your imagination -- anything
but snowmen) and a flock of birds. Both critters will be of the same
type (whatever type you choose) and you will create a class to define
the critter. Similarly you will have a class for a bird.
Requirements for the critter class:
- The instance data should specify the position of the critter
(this will require two variables - one for how far over and one for how
far down), the height of the critter, and the color. You may wish to
have more than one color parameter. The critter should be drawn with
more than one color and you can either let the calling program choose
the other colors (by having more color parameters) or you can choose
them in the class (either use a specific color or a random color).
- The class must have a constructor that has parameters
that specify the position, height, and color.
- The class must have a draw method that draws the critter.
- A critter must have a head, arms, legs, and a main trunk. The head
should have eyes with pupils, a nose and a mouth.
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.
Requirements for the bird class:
Your applet that draws a scene containing birds and critters should
draw a sky and ground (or ocean if your critters swim). It should
instantiate and draw at least 6 different bird objects for the flock
of birds (of course these should be drawn in the sky) and at least
2 different critter objects (which should be on the ground). The
heights of the critter objects should be random (in some appropriate
range). NOTE: Do the random number generation for the height in your
applet and send the height as a parameter (instead of generating a
random height in the critter class).
- The instance data should specify the position and size of the
bird. You can also have a color parameter if you wish to allow
different colors of birds.
- The class must have a constructor that has parameters that
specify the position and height (and color if you include color).
- The class must have a draw method to draw a bird.
- The bird can be very simple. Just be sure what you come up with
sort of looks like a bird.
- Make the critters colorful. Use at least two different colors you create.
- Use good programming style -- meaningful variable names, named constants,
use of white space, proper indentation (note the proper style for indenting
if statements). See the requirements for the last assignment.
- Document your program. Have header documentation at the top of
each file that
gives your name, the date, the file name, and a description of the purpose of
the program. Have internal documentation that delineates and succinctly
(and clearly) indicates what each method is doing.
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 files
(the 3 Java files - you do not need to hand in the HTML file).
Tar the .class, .html, and .java files and email the .tgz file
to email@example.com with a subject of cpsc120 project2.