CST112 Final Exam

  • Using the "Processing" language, and the "Squid" object class that is available in the files at: ../bam/squids.java and ../bam/squid511.java , write a program that satisfies the following specifications,

  • Make sure your code compiles correctly, and upload it to your own Lastname/ folder as a file named final-Lastname.java (where "Lastname" is replaced by your own last name).

  • Standards of good coding practice and readability will apply, and every function ("method") should be preceded by a short comment that briefly states its purpose.

  • Exam is "open book" and you may consult or review code in any of the class folders. However, you should not copy-and-paste any code (other than your own code, or code from the two "squid" filess mentioned above), and -- above all -- make sure that you understand every statement that you include in the code you submit. (Blocks of copied code will be removed before grading, and extra code that does not belong may also result in loss of credit.)

    SPECIFICATIONS

    The "sketch" consists of a blue sky above a dark green sea, where several "squids" race to the surface, moving upward a random amount whenver the "GO" button is clicked (or the space bar is pressed).

    BUTTONS: Four buttons control the motion of the squids, as follows:

    Squids do not move unless a button is clicked (or a key pressed), but "leader" name is always displayed.

    GAME OVER: When any squid reaches the surface, game is over, all motion stops, and the winner and loser are declared (by name, in messages on the screen).

    SQUIDS: When setup or reset occurs, a new set of squids starts at the bottom. The number of squids should be random, from five to ten. The color, width, and number of legs for each squid is also random (but the names remain the same).

    CONSTRUCTOR: should have only the following arguments:
      // Set x, w, and name.  Set h based on w.  Also 
      Squid( float x, String s, float w) {
    	// ++++ ADD YOUR OWN CODE, HERE ++++
        this.w=  w;
        h=  w * random(1.5, 3);            			// h is 1.5 to 3 * w
    	// ++++ ADD YOUR OWN CODE, HERE ++++
      }
      // ++++ (You may randomize color and number of legs here, or do it in reset.)
    
    
    Remove or disable all other constructors.


    *** OPTIONAL - for extra credit. ***

    DAY/NIGHT: * A sun or moon moves slowly across the sky from RIGHT to LEFT,
    switching between night and day, when it reaches the right side (x == 0).
    SUN/MOON: * The sun should be bright yellow during daytime, and change to a pale color at night.
    (NOTE: You may use the same code for both sun and moon; just change the colors.
    SKY * Light blue during daytime; darker blue at night.
    WAVES * should appear on the surface of the sea.
    (After drawing the the rectangular sea, make circles of the same color as the sky, from 0 to width.)

    SWIMMING * Squid legs "swim" by slanting left and right, as the squid rises.

    RESET BUTTON: *


    NOTE:

    Most of the credit on this exam will be given for making the squids race upward, and properly identifying the winner and loser.

    Extra credit will be given for minor [ * or optional ] features such as sun/moon, day/night, legs swimming back and forth, RESET button, etc. as found in the example at http://www.suffolk.li/cst112/51cst112/students/Z/51bam.java ,

    However, the squid arrays and loops are the most important parts!