CST 112 Midterm + Takehome

Using an object-based approach, design a program to meet the specifications given below, then implement it in Java, using the "Processing" language and PDE. Submit your exams by uploading source code into your folder on the class website, using files named: where "Xyz" is first three letters of your last name.

Takehome exam is due next Tuesday, November 5th by 9pm (when polls close, on Election Day!)


S P E C I F I C A T I O N S

FIELD:  Centered on the screen shall be a 300x500 rectangular "field" with horizontal blue lines every 50 pixels (similar in appearance to a football field, with "lines" every ten yards).

FRUITS:  There shall be three "fruits" (an "apple" an "orange" and a "melon"), each moving linearly within the field. The colors of these fruits shall be, respectively, some shade of red, some shade of orange, and some shade of green. The melon shall be the biggest, and the orange shall be the smallest.

ACTION:  The apple shall have the greatest velocity in the X direction ("dx"), and the melon shall have the greatest velocity in the Y direction ("dy"). Each object shall "bounce" off the field boundaries and shall bounce off each other, with completely "elastic" collisions (in which the dx and dy velocity components are exchanged).

CLICK:  Clicking on any fruit shall cause it to be "teleported" to a random location within the field.

SCORE:  The "score" shall increase by 75 or 50 or 25 points, respectively, when the orange or apple or melon is clicked upon (and teleported). The "score" shall decrease by 5 points whenever any object bounces off a boundary, and shall decrease by 10 points when any two fruits collide.

TEXT:  On the screen (but outside the field), the following text shall be displayed:

KEYS:  When the "P" key is pressed, a large "PAUSE" message shall appear on the screen, and all movement shall stop until the key is released (or another key is pressed).
When the "Q" key is pressed, the program shall exit.
When either "R" or "S" key is pressed, the program shall re-start (with fruits at random positions).




OBJECT-BASED REQUIREMENTS

Create a class to represent an object such as a billiard ball (or a frozen fruit, etc. ;^>)
that can have an elastic collision with another, similar object. For this exam, the name of the class must be the first three (or more) letters of your own last name, with an initial CAPITAL letter. If your last name is "Fruit" then the class name is "Fru" (or "Frui" or "Fruit" if you prefer).

Declare three instances of this object, with the following variable names:

Each object of this class should have at least the following eight properties:

For this exam, no more than ONE "constructor" method is allowed for the object class.


CODING & READABILITY REQUIREMENTS



NOTE: You may re-use all of your midterm code in your takehome version.
Specifications for midterm and takehome are identical (but grading will be stricter for the takehome).