COMP 170 Lab 8
CS Home Page
Goals for this lab:
Gain experience with an interface:
Write and use classes implementing an interface
Setup
1. Download lab8files.zip, open the
archive, and extract the
files to a
directory of your choice, and open it in BlueJ.
2. Look at the Game interface. Then look at
AdditionGame, that implements the interface. It uses two
new clearly named List methods remove and isEmpty. See how a new
AdditionGame can be added to list of Games. Run Lab8's main
method. Randomly choosing a game when there is only one to choose
from is pretty silly, but it gives you a start on a more elaborate list
of games.
3. Write several very simple classes
implementing the Game interface, and modify the main method in Lab8 to
create and add a new game of each type. (Test adding one at a
time.)
One such game to create with little more work
would be a variation on Guessing Game, adapting Assignment 3 so
there is a GuessingGame object with a play method rather than static
methods. You could make the maximum number be a parameter
in the constructor.
4. Show the TA when you are
done.