For extra credit, you may optionally implement (5) an additional game (Texas Hold 'Em).
In this lab, you are again encouraged to re-use and modify code from your previous lab solutions - if you choose do this, please put a completely new copy of any header and source files from your previous lab(s) in the new lab project directory you create. This can avoid some potential for error or confusion within Visual Studio, and also ensures you have a backup copy that you could go back to if a modification you try doesn't pan out.
In this lab you may work individually, or in teams of 2 or 3 (but not more) people. Team projects may use any of the team members' previous code in the team's solution.
Note: the details of this assignment are again intentionally somewhat under-specified, leaving you some room to choose what you think is the best way to implement them, as long as what you do is reasonable and you explain your design decisions in comments in the code and in your Readme.txt file.
For this lab assignment, you are especially encouraged to think creatively about how to structure (or restructure) the turn and round methods (including the before, during, and after phases of each): some potentially useful ideas may include having more turns per round, introducing addtional member variables to indicate the different stages of play in each game, or interspersing betting phases with play phases in different ways.
Playerclass to keep track of how many chips the player has. When a player is constructed this variable should be initialized with 20. When players quit or re-join either game, this value (along with their wins and losses) should be stored to or restored from a file (as was done for other information in the previous lab) for that player.
As each player plays they will win or lose chips during betting phases that will occur at different points in each game, and if a player's chip count is ever 0 after a round the player should be prompted (and required) either to reset their chip count to 20 and keep playing, or to quit the game. If a player with 0 chips quits the game and then tries to rejoin the game, they should be required either to reset their chip count to 20 and keep playing, or not rejoin the game after all.
FiveCardDrawclass so that:
During a phase, if no other player has bet so far, the next player may either check (staying in the round but not risking any more chips at that point) or bet either 1 or 2 chips.
Once a player does bet during a phase, then the other players must either fold (dropping out of the round and having their chips bet so far in that round pushed into the pot), call all previous bets and raises that they have not called (by increasing their cumulative number of chips bet to match the highest cumulative bet of any other player in the phase so far), or raise 1 or 2 chips in addition to the amount needed to call any earlier bet or raise.
If a player runs out of chips during a phase, they will remain in the round with no further obligation to call, bet, or raise in that phase (or any subsequent phase) until the round is over. For simplicity they will be able to win the entire pot (or a split of it in the case of a tie) if their hand is highest (if you would like to do so you may instead choose to implement support for side pots, though it is not required to do so).
If all players check and no-one bets the phase simply ends without any chips being added to the pot. If someone does bet the phase continues until the most recent bet or raise has been called by all remaining players or until all but one player has folded. At the end of the phase all chips bet (including those by players who later folded) are pushed into the pot.
If all players except one decide to fold, then the entire pot is awarded to the remaining player, their win count is increased by one, and the round ends.
Otherwise after the last betting phase of a round the hands of the players that remain are ranked, the pot is added to the chip count of the player with the highest hand (or is split among the players having identically highest hands if there are ties at the top), and the winning player(s) win count is increased by one and the other remaing players loss counts are increased by one.
SevenCardStudclass. Make sure that it implements all of the common features of your
FiveCardDrawsolution, and in fact one good approach is to move as much common functionality as possible up into (possibly private) methods of the
Gameclass or of an intermediate class (e.g.,
PokerGamewhich is derived from
Game) . For example collecting antes, saving and restoring players, handling the cases where a player runs out of chips during a round, announcing the winner(s) at the end of each round, etc. should work essentially the same in all games.
Please implement the following features in your
FiveCardDrawgame, except that there will be five phases instead of two.
FiveCardDrawin which each remaining player will have exactly 5 cards in their hand, in
SevenCardStudeach player still in the round when it ends will have 7 cards from which to choose their best 5 cards. For each remaining player at the end of each round (unless all but one have already folded) your
SevenCardStudgame should choose the highest ranking combination of 5 of their seven cards, and use each player's best possible hand to determine the winner(s) of the round.
Gameclass and your main function so that (1) "SevenCardStud" is recognized as a valid name of a game, and when it is provided should result in a
SevenCardStudgame being created and played; and (2) after any game is finished the program should stop (and destroy) the previous game and then prompt the user whether to play a new game or quit the program. If the user chooses to play a new game the program should prompt for the name of the game and the names of the players (re-prompting for whether to quit or play again etc. as needed if an invalid game name is given).
If at any point the program encounters an error that will not allow it to continue, it should generate an error message and return an approprate non-zero error code.
Send the zip file containing your lab 4 solution as an e-mail attachment to the course e-mail account (firstname.lastname@example.org) by the submission deadline for this assignment. If you need to make changes to your lab solution you are welcome to send a new zip file, and we will grade the latest one received prior to the deadline (according to the time stamp the server puts on the e-mail).
To do that, you should implement the following additional features beyond those in Part II:
TexasHoldEmclass. Make sure that it implements all of the common features of your
SevenCardStudsolutions, and as noted earlier one good approach is to move as much common functionality as possible up into (possibly private) methods of a common base class. For example collecting antes, saving and restoring players, handling the cases where a player runs out of chips during a round, announcing the winner(s) at the end of each round, etc. should work essentially the same in all games.
Please implement the following features in your
FiveCardDrawgame, except that there will be four phases instead of two.
SevenCardStudin which each remaining player will have their own cards, in
TexasHoldEmeach player still in the round when it ends will choose their best 5 cards made up from the 7 cards including the 2 cards dealt to them and the 5 cards shared by all players in that round. For each remaining player at the end of each round (unless all but one have already folded) your
SevenCardStudgame should choose the highest ranking combination of 5 of those seven cards, and use them to determine the winner(s) of the round.
Gameclass and your main function so that "TexasHoldEm" is recognized as a valid name of a game, and when it is provided should result in a
TexasHoldEmgame being created and played.