|
|
|
|
|
|
|
Testing: To exhaustively test this program, all possible configurations of a deck of 52 cards have to be generated. Although this is theoretically possible, it is not realistic. There are 52! [52 factorial] possible arrangements of a deck of cards, and 52! equals |
|
|
|
|
|
|
|
|
This is a large number. Try multiplying it out. |
|
|
|
|
|
|
|
|
Therefore, another method of testing is required. At a minimum, the questions to be examined are: |
|
|
|
|
|
|
|
|
1. Does the program recognize a winning hand? |
|
|
|
|
|
|
|
|
2. Does the program recognize a losing hand? |
|
|
|
|
|
|
|
|
To answer these questions, we must examine at least one hand declared to be a winner and several hands declared to be losers. Specifying 20 as the number of games to play, we ran the program to see if there were any winning hands. There were none. |
|
|
|
|
|
|
|
|
From past experience, we know this solitaire game is difficult. We let the simulation run, specifying 100 games and an initial seed of 3. There were two winning hands. Intermediate output statements were put in to examine the winning hands. They were correct. Several losing hands were also printed; they were indeed losing hands. Satisfied that the program was working correctly, we set up runs that varied in length, number of shuffles, and seed for the random number generator. The results are listed below. There is no strategy behind the particular choices of parameters; they are random. |
|
|
|
|
| Number of Games | Number of Shuffles | | Games Won | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|
|
|
|
|
In this chapter, all the functions that deleted a value from a data structure assumed that an item was there to be deleted (DeleteTop and RemoveTop) or that the specific item to be deleted was in the list (Delete). The calling code was responsible for guaranteeing this precondition. |
|
|
|
|
|