CST 112 Final Exam
Modify your Project #4 code
to use arrays of Object.
Make a copy of your
Project #4
code;
modify it as described below.
Store your final code in a new file named
"q4.pde"
by 5pm Tuesday 5/19.
M O D I F I C A T I O N S
(1.) Increase the number of Racers
from three to five.
You will also need six buttons and four varmits.
- Replace the three racer objects
with an array of five Racer objects.
- (Modify the screen size, if necessary.)
- Replace the four buttons with
with an array of six buttons.
- (Make sure each button is same color as corresponding Racer.)
- Replace the two Varmits with
with an array of four Varmits.
- Use for
loops to traverse the arrays.
- Do not refer to individual racers, such as
r[0] or r[4];
- instead, use
r[j]
within the repeating block of each for loop.
- To make things easier, use the subscript number
as the "name" of each racer.
For example,
if j
is the subscript of a racer
in an array r[],
then this statement changes its name:
(2.) Add markers across the tracks,
Use a while loop to display the lines and triangles,
as shown in this screen-shot:
Specifications for
p4
are summarized
below.
These specifications
should apply for arrays of objects in q4.
|
Define and use these object classes:
Properties should be defined within the object class.
(Global variables should not be used within the class.)
.
- Racetrack:
-
A racetrack with
three
five
parallel tracks (horizontally).
- Racers:
-
In each track, a racer
moves
(a random amount)
when its button is clicked.
Each racer is a different color,
and drawn with at least three shapes..
Buttons:
-
Buttons are used to make the racers move:
-
Each button
must be the same color as its corresponding racer
and
display the name
(or number)
of that racer,
An additional button moves ALL
three
five
Racers.
- Varmits:
-
After the race begins,
two
four
small varmits
run back and forth between the tracks
(bouncing off the ends).
- Animation:
- Racers and Varmits should all display some sort of animation, as they move.
- Messages
- The title and author must appear on the screen.
When a racer crosses the finish line,
the winner's name
(or number)
is displayed.
|