Published using Google Docs
War Card Game
Updated automatically every 5 minutes

War Card Game

Dynamic Data Structures 1

Note: There is absolutely no requirement to create a GUI for this assignment.  If you are interested in doing so, however, come see me first so we can discuss whether or not you have time.

Come see me before beginning so you can see a sample run of the code and to discuss possible additions to the requirements.

Your goal is to create a War Card Game using a Queue. Recall that Queues use the first in, first out thinking.  For this assignment, this means that cards come off the top of one hand and then are continuously placed back on the bottom of the winner’s hand.

Use the following  code example to set up your Queues:

Queue <String> queue_name = new LinkedList().

String is the data type that your queue will hold.  For this assignment, your queue will be holding instances of your card class so it should look like: Queue <Card> queue_name = new LinkedList()

Never played War?  Here is a link to the rules.  I would be happy to show you too.

You are going to create 2 classes:

The Card class should:

 

The WarGame class will take care of the following:

Entirely Optional Challenge

Evaluation

Setting up Card class and queues                40%

isHigher() method                                10%

Game Play                                        30%

Determining the winner of the game                10%

Good Coding and Commenting                        10%

Want to pause between flips of the cards?

I have had a few students ask how to make the program pause for a few seconds before moving on.  Want to know how to make your program pause?  Try this:

try {
   
Thread.sleep(1000);
}
catch(InterruptedException ex) {
   
Thread.currentThread().interrupt();
}

 

The 1000 is milliseconds so 2000 is a 2 second pause.