CST112 Final Exam
Using the "Processing" language, write a program according to the following specifications,
and upload your code into your folder with the name "final_xyz.pde"
(replacing "xyz" with the first three or more letters of your own last name)..
In your code, declare a global array of twenty integers,
named with your own first name.
(Use only lower-case letter, please!)
Intitialize this array values to random values, during the setup() method.
Please note that your array MUST be named with your own first name (or at least the first three letters of it);
no credit will be given if the array is named a[].
Use the "Button" and "Ball" classes object found in
http://suffolk.li/cst112/19cst112/tuesday/final_sample.pde
and modify as necessary.
Your code should be fully-modularized,
with the "draw()" method containing only calls to other methods.
(Your draw() method should not contain any "drawing" commands, such as rect(), etc.)
Be sure to precede each of your methods with a comment line saying what it is supposed to do, and
follow all coding standards given for previous assignments (projects, exams, etc.) and in class.
As always, "readability"
of your code
will be a significant component of the grading!
SPECIFICATIONS:
- Screen size is 640x480, with pale-yellow background..
- Your name should appear in blue, at the bottom of the screen, at pixel position (10,480).
- Near the upper-right corner of the screen,
display the mean average of all values in the array.
- Display the twenty values of the array in black,
at the bottom of the screen with each number 25 pixels apart horizontally:
(i.e. at pixel positions (100,480), (125,480), (150,480), etc.)
- Above each of the twenty values, display a rectangular "bar" whose height is
four times the value of the array element. The color of the bar should be green, unless otherwise noted.
Make the bars 20 pixels wide, with their bottoms 30 pixels above the values
(i.e. at pixel positions (100,450), (125,450), (150,450), etc.)
- Along the top of screen, display a row of circular buttons (using the "Button" class mentioned above),
identified by letters of the alphabet (A, B, C, ...).
Each button should be a differently-colored circle 40 pixels in diameter,
with its identifying letter near the center.
-
In addition to its name (one-letter),
each button should also display the number of times it has been clicked.
(You must add a new property to the Button object,
to keep track of this count, update it when the button is clicked,
and display it when the button is shown.)
-
Modify the "show()" method (of the Button class) so that
the button color is changed to gray
whenever the mouse is over that button.
- When a button is "clicked", perform the task described below:
- Change the background color, alternating between light-green and light-blue.
Change background light-green, the first time this button is clicked, and on every other click.
If the number of clicks is even, then the backgound should be light-blue.
- When this button is clicked, find the largest and smallest values in the array, and swap them.
- When this button is clicked,
replace each array element with a random value between zero and 100.
(Don't forget to recalculate the mean average, whenever this occurs.)
- When this button is clicked, change the array as follows
(and recalculate the mean average):
- Double all values that are less than the mean average.
- Subtract 50 from all values that are greater than the mean average
- When this button is clicked, change the array as follows
(and recalculate the mean average):
- Add ten to all even values in the array;
- Divide all odd values by three.
- When this button is clicked,
create a new ball (30 pixels diameter, randomly colored)
which moves diagonally (down two pixels and right three pixels, every frame),
beginning at a random height on the left side of the screen,
and "bouncing" off all edges of the window.
Make the ball vanish, if it gets near (within 50 pixels) of the mouse!