CS230 Data Structures, Wellesley College

[CS230 Home Page][Syllabus] [Students][ Assignments][Documentation] [CSDept.] [CWIS]

Lab 7

This Means War!

In this lab, we will design and implement a program that will allow you to play a simplified version of the card game War with the computer. We will use the Card and Deck ADTs (home made), and the Java Stack ADT in our implementation of the game.

The rules of our simplified War card game are as follows.

We will start by trying to identify the objects involved in this application. What are some actions these objects should be able to perform?

As we are discussing and analyzing the application, you can go ahead and cvs update your cs230 account.

Look at the Card.html documentation file to see what methods have already been defined, and therefore are available to you as a "client" of that class. At a later time, please study the implementation of each method in the Card.java, as it is rather interesting!

Do the same with the Deck.html documentation file. At an other time study the impelmentation details in Deck.java You can see how my version of the War game is running, by running the executable War.class file, which is among the files in your lab7 directory.

Your main task is to implement the War class, which is where actually the game is played. Use the Java built-in Stack class, to represent a LIFO stack of Cards. Check the on-line Java documentation to find out what package you need to import, and what methods are available in the Java Stack class. You should start your implementation with the provided War.java code file. It contains a couple of helper methods, which hopefully will help you as you develop your code.

You should add a main() method, in the WarGame code file, to test your new methods as you add them.