CS230 Data Structures, Wellesley College, Fall 2008

It's War!
playing cards

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:

 

Where do we start?

Questions: what are the objects involved in this application? What are some actions these objects should be able to perform?

Check out the Lab06 directory in the download folder. Download all these files into your Lab06 folder.

Read the Javadoc generated documentation files for the Deck and Card classes. This will tell you what methods have already been defined and are therefore available to you as a "client" of that class. (These HTML files were created, based on the Javadoc-style comments, by running this command in linux: javadoc Card.java -d doc ).
Here are the steps taken to create the .html documentation files for these code files. From your lab6 folder, try this:

javadoc Card.java -d doc
Repeat that again for Deck.java. Then look inside the doc folder. In order to view Card.html in a browser, we need to make it publicly accessible. One way to do this is to copy the entire doc folder into your public_html folder. Navigate to your public_html folder, create a doc folder, cd into the (newly created) doc folder and then copy the contents of your cs230/lab6/doc folder into it. The comments are in red.
cd                (navigate to your home directory)
cd public_html    (go to your public_html directory)
mkdir doc         (make a doc folder)
cd doc            (change current folder to be doc folder)
cp -R ../../cs230/lab6/doc/* .         (copy the javadoc files to the public doc folder)
Now we need to fix the permissions on the files to make them viewable online. From inside your doc folder, you need to make the individual files viewable:
chmod 644 *.*
From your public_html folder, this makes the doc folder viewable:
chmod 755 doc
Now, try viewing the Javadoc documents from the browser. Here's a link with more background information about chmod. Here is a useful Introduction to Javadoc. You can run our version of the War game, by running the executable War.class file (found in the /home/cs230/download/Lab06 folder).

Your task: this means war!

Your main task is to implement the War class, which is where actually the game is played. Here are some notes: