More Elaborate Projects

  • Bob Dukish


In Chapter 6 we experimented with coding the game of poker and were able to put together a very simplistic version of the game. The advanced program in this chapter builds on the earlier code for generating nonduplicate numbers to represent the cards in a playing deck. It deals five random cards to the player and five to the dealer (refer to Table 6-1 for card value translations). The code in Listing 9-1 goes on to identify both hands by using the rules of poker. At first glance, it looks like a tremendous amount of code, but because the player and dealer sections are similar, much of it can be copied and pasted with only minor alterations. It is left to the reader to generate the additional code needed to identify a winner if desired. My intent is to only show how a computer program can act in accordance with a set of rules. You might also wish to rework the code using functions (subroutines) to eliminate some repetition and provide for better overall organization.

Copyright information

© Bob Dukish 2018

Authors and Affiliations

  • Bob Dukish
    • 1
  1. 1.CanfieldUSA

Personalised recommendations