Project 1 - A Dice Game

Due - Tuesday, February 15, 2005

The goal of this project is to give you an opportunity to brush up on your programming skills. This project does not require advanced features of C++, but you should use all of the features of C++ that we have discussed so far.
In this project, you will write a program to play a dice game. This game is a dice version of poker and is played as follows:
The game is played by two players and goal of the game is to have a better hand than the other player. Player 1 rolls 5 six-sided dice. Player 1 may then choose to re-roll 0, 1, 2, 3, 4, or 5 of the dice. After her second roll, it becomes player 2's turn. Player 2 rolls a second set of 5 dice and may choose to re-roll any subset of her dice for a better hand. After both players have rolled, your program must determine and declare a winner. Hands are ranked as follows:
HandRank
five of a kind1
four of a kind2
full house (2 of one number and 3 of another e.g., [2, 3, 2, 2, 3])3
straight ([1, 2, 3, 4, 5] or [2, 3, 4, 5, 6])4
three of a kind5
two pair6
one pair7
If both players have the same hand, the player with the highest-value hand wins. For example, if player 1 has one pair of 2s and player 2 has one pair of 3s, player 2 wins.

Implementation Hints

To simulate the roll of a six-sided die, you should use the C++ function rand(). You should use (and cite!) external resources to help you understand how to use the function rand().

Your design will be part of your grade. I recommend that you think carefully about how to separate the functionality of this program into functions.

Due Tuesday, February 15, 2005

  1. Complete and submit your working code.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input paramaters and ouput.
  3. Run your program on a variety of inputs ensuring that all error conditions are handled correctly. Copy and paste the output of your test runs to the bottom of your program. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.

Sami Rollins