The Shell Game

To illustrate the use of pointers in another example, we will write a program for another game; the Shell Game.

The Algorithm

     repeat the game
          initialize the data structures for empty shells
          pick a location and place the pea
          show the mark
          when the mark is ready
          shuffle the shells 10 times
          show the backs of the shells
          get the mark's guess
          check if correct
               increment score
          show the contents
     while the mark is still gullible (and has more $)
     show the final score

The Design and Implementation


[up] to Overview.