Lab 08: War!

In this lab, you'll create the classic, almost completely brain-dead game of War. You split a deck of cards evenly between two players and both play the top card in your hand. Whoever plays the higher card takes the two cards and adds them to their discard pile. When you run out of cards, reshuffle your discard back into your hand and keep going. When one player has all the cards, they win the game. For even more simplicity, in our version if there is a tie, the two cards are thrown out.

Here is example output:

To implement this game, you'll be working with a number of functions with arrays. The "cards" only need to be integer values, and the deck, hands and discard piles can all be arrays of ints.

This lab08_war.cpp file has the game already broken down into functions. It's your job to complete those functions to finish the game. In order to do so efficiently, you should:

  1. Read the whole .cpp file to understand the structure of the program.
  2. Create a .cpp file of your own.
  3. Copy the functions over from the game one by one into your file. Make them work and test them there in that separate file, rather than trying to test in the middle of all the game code.
  4. When the functions are working, bring them back into the game and finish it.