CPSC 120B Fall 2002
Program 2: A Day at the Beach
Due Friday, October 11
Write a Java applet that draws a beach scene containing the following:
- Sand (beach) in the foreground (bottom of the page), then water, then sky.
- A quarter-circle sun in the upper left-hand corner with at least 5 rays.
- Two beach umbrellas, of random size (within some reasonable range) and at random
locations within the beach. The poles for
the umbrellas should both be in the sand (of course), but
the umbrella parts may appear to extend into the ocean. The larger umbrella should
appear to be
"closer," that is, it should be further down on the page. If the umbrellas
overlap, be sure the closer one obscures part of the farther one, not vice versa.
- A bird or a fish (sometimes) as follows: Randomly choose a point somewhere on
the screen. If the point is in the sky, draw a simple bird at that
doesn't matter where on the bird the point lies). If the point is in the
ocean, draw a simple fish at that point
(it doesn't matter where on the fish the point
lies). Note that if the fish is behind an umbrella, it won't show up.
If the point is in the sand, do nothing.
You will also need to construct a .html file to display your applet.
Style and Documentation
Your program should be cleanly written with good variable names and
appropriate use of whitespace. Documentation should
include the standard
header plus comments explaining any complex or unclear sections of code.
Comments should also be used to introduce logical sections of code. You will
find that this program is much easier to follow if you break it up into
short, logical components.
Using literal values for drawing parameters (coordinates, widths, etc.)
can make it difficult to understand what those values mean and even more
difficult to make simple modifications to the program. Be sure you use
named constants as appropriate.
What to turn in
Turn in hardcopy of your .java file. Tar up your prog2 directory
and e-mail it to firstname.lastname@example.org with subject cpsc120 prog2.