Next: About this document
Up: Example: designing an automatic
Previous: Second Iteration
Now we are ready to design/code each SUB. This is left for the reader to do.
Here are some hints.
- You can use SELECT CASE ... END SELECT in SUB InitializeDeck to
assign words to suits, or even characters CHR$(3) - CHR$(6).
- Use STATIC variable to remember which card to deal from in
SUB DealCards(n)
- Since we have only 52 cards, randomization in
SUB ShuffleDeck doesn't have to be fast. But you may want to implement there
a more realistic simulation of shuffling (cutting deck in half, mixing the halves, etc.)
- To implement a reasonable error detection in
FUNCTION HowManyCards% you may just reject requests for negative number of cards,
and for more than 52 cards. INPUT statement has some protection built in
-
fractional numbers will go through, but strings at least will be stopped.
- SUB DealCards(n) is the best place to check if there is enough cards left.
(If not, request FUNCTION HowManyCards% from there again).
Send comment