CPSC 120 Assignment #2
Completed Assignment: Friday October 27, 2006 by 4:00 p.m.
Phase I: Friday October 13, 2006 by 4:00 p.m.
In this assignment you will create classes for three graphical objects:
an umbrella, a cloud, and a raindrop. These classes could be used
to create many different scenes. To illustrate the flexibility you will
use them in two different scenes - a beach scene and a weather scene.
Phase I
For this phase you will create the umbrella class and a basic beach
scene. Be sure to create a subdirectory of your projects
directory for your work.
For phase I create the following files.
Umbrella.java In this file you will define a class that models
a simple umbrella with the following characteristics:
- An umbrella will be represented by its location, its width when
open, it color, and whether or not it is open.
- An umbrella will be composed of a hood (half an oval) drawn in
the color of the umbrella and a post (a skinny rectangle) drawn in
black.
- When open, the width of the hood of the umbrella will be the
given width and the height of the hood will be some fraction of
that (you decide what looks good). The post should be at least one
and a half times the width of the umbrella hood.
- When closed, the hood will be represented by a very skinny
half of an oval (how high should this oval be?). The total
height of the umbrella should be the same as when open but less of
the pole will be showing. (HELPFUL HINT: If you draw things in the
right order you don't have to worry with re-computing the length
of the pole - think about it!)
The umbrella class will have only two methods (unless you have
enhancements you want to add): a constructor and a draw method. To
instantiate an umbrella a program should be able to specify its
location, its width, its color, and whether or not it is open. So,
STEP #1: THINK carefully about what parameters the constructor
needs including what type each is.
Note that the class will have just one draw method. If the
umbrella is open it will draw an open umbrella otherwise it will
draw a closed umbrella.
Beach.java This is the main applet for the beach scene. It
should contain the following:
- Sand in the foreground (at the bottom of the page), water,
and sky. You will need to create your own color for the sand since
none of the predefined colors in the Color class look like sand.
- A sun in the corner.
- At least 3 umbrellas at different positions (sort of staggered -
not all lined up in a row). Be sure that all the umbrellas have
their poles in the sand! At least one umbrella should be closed
and at least one open.
Beach.html Of course you need a simple HTML file to view
the Beach applet.
Hand in by Friday October 13: Your Umbrella.java and Beach.java
classes. Also tar your project directory and send it in an email.
For the remainder of the project you need
to create classes for the cloud and raindrop objects and applets
that use these objects. Specifications for these will be
handed out later.
General documentation requirements:
- 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. For the files that have classes defining an object
the documentation should also give the attributes of the object. For example,
an umbrella has a location (specify what this means - is
it the top center, the left corner, what does it represent?) among other
things.
- In your files that define objects, have clearly visible (with borders!)
documentation before each method describing what that method does.
- Have internal documentation that clearly delineates and describes
what is happening in major sections of code (for example, before you
draw something state what is being drawn - such as "draw the sand").
Grading
If you do not turn in phase I or if you turn in something that
doesn't show a good faith effort you will automatically have 10 points
deducted from your final assignment grade. Otherwise your work in
phase I will not hurt you - it will be turned back to you the Monday
after break with comments to help you improve it.
Your final project will be graded both on style and correctness.
Style includes
adherence to rules for naming of identifiers, use of
constants, 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 (this includes Phase I of this
assignment). 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.