Computer Science APEA 15-100, Summer 2009
Lab 8


Read these instructions first!


Note:  You may use loops and conditionals now.  You may not use Java concepts we have not yet covered, including arrays or methods from any classes in java.util.* to solve these problems.  Also, you may only use the charAt and length methods from the String class.  While they may be helpful, every problem here is solvable without them.


Also note:  For each of these problems, you should write your own tests!


  1. Hw7 solutions (quickly)
     
  2. Experimental Math:  Discovery
    Finish all the "discovery" examples from today's lecture notes.  (Actually, just finish a couple during lab time, leave the rest to the weekend to finish.)
     
  3. Stars
    Using the star code from class, draw the flag of Panama (with stars, of course).
     
  4. 2d Loops
    Using two "for" loops, draw an 8x8 checkerboard.
     
  5. Checkerboard Animation
    Animate your 2d loops checkerboard example so that a single checker starts in the lower-left (which we will assume is a red square) and in turn visits every red square on the board in whatever pattern suits you.  Try some variants on the pattern, too.
     
  6. Simple Game
    In a file named Lab8SimpleGame.java, write this Simple Game.

    Note:  If this applet does not run in your web browser, you can try running this equivalent jar file:
       simpleInvadersGame.jar

    Note that you move the blue paddle with left/right keys, and fire with the space bar.  The red ball is fired randomly (though always downward).  You should use bounding boxes for all collision tests (this makes the game a bit easier to implement).  Play the game in order to determine the rest of the design spec.

    Note:  you are not likely to finish this during today's lab session.  The remainder of this problem (and the rest of the lab!) should be completed collaboratively over the weekend.

    Also:  you will have to use the page.drawString method and page.setFont methods, such as this:
       page.setFont(new Font("Arial",Font.BOLD,16));
       page.drawString("Carpe diem", 50, 100);

    The first line sets the font to use for subsequent text.  The 16 is the point-size of the font.  If you don't want bold, you could replace Font.BOLD with Font.PLAIN.  The second line draws the string "Carpe diem" so that the its left baseline (roughly its bottom-left) is at the location (50,100).  You are not expected to exactly locate strings vertically (for now, close is close enough), so don't worry about where exactly the baseline of the string is.

Carpe diem!