MIDTERM EXAM -- CST 112 (Fall 2014)
In-class portion: (Halloween week)
(Take-home portion due next Wednesday)
Using the "Processing" language,
create a "sketch" that meets the SPECIFICATIONS given below.
-
IN-CLASS:
Upload your midterm souce code to your own folder,
in a file named "XYZ-midterm.java"
(where XYZ are YOUR initials, in UPPER CASE).
-
TAKEHOME:
Upload takehome souce code to your folder,
in a file named "XYZ-takehome.java"
(where XYZ are YOUR initials, in UPPER CASE).
SYNTAX:
All code must be syntactically correct;
code that fails to compile (or run) will be ignored.
CODING STANDARDS:
Readability of code is an important grading criteria
for both the in-class and the takehome portions.
Coding Standards [SEE BELOW] will be strictly enforced on the takehome portion,
and credit will be deducted on the takehome portion when they are not followed.
SPECIFICATIONS
- SCENE Screen is 600 pixels wide by 500 pixels high.
-
On the screen, display a "title" (centered, at the top)
that identifies the purpose of your software,
and an "author" line at the lower left) that contains your name & publication date.
- The top half of the screen is the
"SKY" [see below]
and the lower 3/4 of the screen is the "OCEAN" [see below].
(The "surface" of the ocean is at height*3/4.)
BEWARE: Various creatures traverse or lurk within these two regions, and may commit nefarious actions within during the day or night!
- BORDERS The top, left, and right sides of the screen are decorated with a "border".
- Each border is one of the following patterns, repeated uniformly across the screen:
OPTIONAL: Make each of the three borders have a different pattern.
- Semicircles
- Squares
- Triangles.
- DAYTIME (when the boolean variable "day" is true")
- During the daytime,
the sky is light blue,
a yellow sun appears in the upper-right portion of the sky,
and a "BIRD" [see below]
flies across the sky, from RIGHT to LEFT, every four seconds.
(To move 150 pixels per second, at thirty frames per second,
the x value should decrease by about 5 pixels per frame.)
- BIRD:
(flies across the daytime sky,
every four seconds)
-
The bird consists of two large purple triangles.
- NIGHTTIME (when the boolean variable "day" is false")
- During the night,
the sky is darker,
a pale-pink, crescent moon appears in the MIDDLE of the sky,
The "WITCH" [see below]
flies on her broom, across the night sky,
from RIGHT to LEFT,
every ten seconds,
and the
"OCTOPUS" [see below]
slowly bobs up-and-down,
from the bottom of the sea to the surface
(during the nighttime only).
- WITCH
- The WITCH
consists of a black triangular hat,
a red face,
a brown rectangular body,
and two green legs,
riding on a BROOM
that has seven (7) bristles.
(See image at the right.)
USE A LOOP TO MAKE THE BRISTLES
The WITCH flies across the night sky,
every ten seconds, from RIGHT to LEFT.
- The OCTOPUS
slowly bobs up-and-down,
from the bottom of the sea to the surface
(at night).
-
The octopus consists of a dark body
shaped like a "mailbox"
with a round top,
(see image),
and eight legs below.
USE A LOOP TO MAKE THE LEGS.
All eight legs should slant, either to the left or to the right, every few frames,
when the octopus is rising,
but go straight downward when the octopus is sinking.
TEXT: The following text should also appear on the screen:
- Title at the top center of the screen should say: "CST 112 Midterm"
(or "Takehome")
- At the lower left corner of the screen, display your name.
EVENTS:
CLICK:
Clicking causes different effects,
depending upon WHERE the mouse is located.
- Clicking near (within 20 pixels of) the witch changes from night to day.
- Clicking near the bottom of the sea causes the octopus to start rising from that X-coordinate.
BUTTONS:
Clicking on a button does the following:
- DAY: Change from nite to day.
- NITE: Change from day to nite.
- QUIT: Exit this sketch.
- BIRD/WITCH: Restart the BIRD (if daytime) or the WITCH (if nite)
NOTE: The button should say "BIRD" or "WITCH" depending on whether it is day or nite.
at the side of the screen.
CODING STANDARDS
COMMENTS:
- Begin each file with
with comment lines that give your name and the project identification,
then briefly say what your code is supposed to do
(when it is debugged! ;^> ).
- Always begin each function ("method")
with a comment line that briefly says what this method is supposed to do
(assuming it works! :*)
- Comment any code that is non-obvious.
ALSO:
- MODULARIZE:
- Break up the problem into smaller pieces, to be coded seprately (as functions).
- ARGUMENTS:
- Use function arguments
to inputvalues needed by functions
(rather than using globals!)
- PARAMETERIZE:
- Use variables
rather than constants
to describe arbitrary quantities
(such as widths and heights of creatures, distances, etc.)
- NAMES:
- Choose meaningful names for symbols (variables, methods, etc.)
BgColor=WHITE