Lists Lab (War card game)
- For this lab you are to write a program to simulate the playing of the card game War (see wikipedia for the rules).
- The program should use use data structures for the Java library (not your own). You may only create specific to the game or war. You may not (directly or indirectly) create or use your own linked lists or arrays. For your collections of cards, you are to use the Java library. It is recommended you use lists and queues.
- You are to output what happens each round.
- You can decide when happens if a user runs out of cards while dealing with a tie.
- You need to output who won.
For this lab, I am included suggestions as to steps for development. You don't need to follow them. But if you get lost and are asking me for help, this is where we will start (except for some simple debugging).
- Step 1: Create a Card class. Use names constants for the suits and face cards. Implement equals, toString, and compareTo (implement Comparable). Cards do not change their values. Compile it and create two cards to test.
- Step 2: Create a Deck class. STart with just the constructor. It should create the deck (using a data structure) and place all 52 cards in it (in a set order). Implement the toString method. Create an instance and invoke the toString to make sure it works.
- Step 3: Implement a shuffle routine. It should take a random item out of the deck and then place it back in a new random position. It should do this 52 times. Test by creating a list, shuffling it, and invoking toString to see that it is shuffled.
- Step 4: Add a "deal" method that will get the top card from the deck and return it. Make sure it compiles and works.
- Step 5: Create a "Hand" class that is a queue of cards. A hand starts out empty. Cards are added to the hand and removed from the hand (as a queue) -> for the game of war. It also knows when it is empty. Compile and test.
- Step 6: Don't start this until the rest is working! Work on the game. First write the constructor. It should create a deck and two empty hands. It then shuffles the deck and hands out the cars (one at a time) to each of the players (each gets 26 cards). Does it matter if it alternates or deals out all 26 at a time to one player?
- Step 7: Write a routine to play one battle. Recursion can make handling a tie very easy. First write out the logic in English!
- Step 8: Write a driver.
Create a software development report that includes the following:
- A problem summary (the big picture)
- A list of requirements. (Things that this particular implementation of a solution must do)
- A list of steps your program does
- A testing report: Since there is no input to this program, you must give evidence that it works (saying it works is not evidence). You can include the evidence that each class (deck, hand, card) works. Then give evidence that the war game actually works.
- How long it took to write the program
- Who you got help from (if you got help)
- At least two things you learned while writing the program
- Changes (if any) you would make if you had more time and/or skill
- Create a zip folder with your software development report and your java files and submit that to canvas.
Due date can be found on canvas