Graphic by Keith Ohlfs
CS111, Wellesley College, Spring 2000

Problem Set 8

Extra Credit

Due: Monday, May 1 at 11:59pm

[CS111 Home Page] [Syllabus] [Lecture Notes] [Assignments] [Programs] [Documentation] [Software Installation] [FAQ] [CS Dept.] [CWIS]

 

Associated with Problem Set 8 are three extra credit problems, which are described below. All are optional, but we encourage you to do at least one. You may do all three if you like.

The extra credit problems are due on the night of Monday, May 1, to give you a little more time to work on them.

The three extra credit problems are described below. Here's a quick overview

To submit an extra credit problem, follow these steps:


Extra Credit Problem 1 (3 points): Acing Blackjack

Implement a version of the handPoints() method from PS8 Problem 3 which calculates the maximum value of the hand without going over 21 taking into account that aces could be high (11 points) or lo (1 point). If this is not possible, handPoints() should return the minimum value of the hand, which will be greater than 21.

For your convenience, the IntList methods are available in the BlackjackGame if you wish to use them (i.e. you may say empty() instead of IntList.empty()).


Extra Credit Problem 2 (5 points): Screensaver

In this problem we will create a classic screensaver animation. A working demonstration of the screensavers is available from the link above and in the Test folder of ps8_programs. This particular screensaver is a design made of a polygon. We will represent a polygon as an array of Points. A Point is a Java object (part of the graphics library) and its contract is as follows:


Point Contract

// Public instance variables
int x; // x-coordinate of Point
int y; // y-coordinate of Point

// Public Constructor method
public Point (int x, int y);


Since we know what all the instance variables of a Point object are, we draw its representation in ObjectLand as a concrete representation (with straight-edges).

Task 1: MorphingPolygon1

Your task is to flesh out the implementation of MorphingPolygon1. The skeleton for this class is in the file MorphingPolygon1.java. Abstractly, MorphingPolygon1 has the following state variables:

dx and dy stand for how much each Point's x and y coordinates should change with each frame (the points in the polygon move independently at different speeds and in different directions). The following are some notes on the methods that you are to flesh out:

Task 2: Object Diagram for MorphingPolygon1

Draw an Object Diagram for the result from the following call:
MorphingPolygon1 mp1 = new MorphingPolygon();
Where random numbers or colors are involved, insert your choice of random numbers and colors. We should treat the Sprite class as a black box in our representation of MorphingPolygon1 (i.e. we only want to see the instance variables for this class and not its superclass Sprite). Your drawing should match your implementation of MorphingPolygon1 from Task1.

Task 3: MorphingPolygon2

MorphingPolygon2 extends MorphingPolygon1 to allow for drawing Polygons of different "widths". A width of 1 means that the polygon is drawn once. A width of 2 means that the polygon is drawn twice and the second instance of the polygon is offset a little bit from the first one. The skeleton for this class is in the file MorphingPolygon2.java. The guidelines for fleshing out this class are as follows:

To test your Sprites, try out the animations in the ScreenSavers.html file. Each constructor is showcased in a separate animation so you can see if it behaves correctly on its own.


Extra Credit Problem 3 (up to 5 points): Open Ended Animation World Design

This is an open-ended problem to design and implement an interesting animation in AnimationWorld. The possibilities are endless! Do something that you find creative and fun. The number of points awarded will depend on the creativity, artistry, and technical skill involved in producing your animation.