'PROGRAM: GIVECARD.BAS
InitializeDeck
ShuffleDeck
'ask first player
n=HowManyCards
DealCards(n)
'ask second player
n=HowManyCards
DealCards(n)
What remains is only to decide what each step should do, and how the information about the cards will be stored. Since storing the information determines how it is passed between subprograms, we begin with determining this part.
We may want to use an array Deck(52) which will be of ``user defined" type. The advantage of this approach is that we may modify the information we w ``store" with each card with minimal changes in the program itself.
DEF TYPE Cards
Suite as string
Value as integer ' we may want string here, too!
End type
Afterwards we may declare two shared arrays
Dim Shared Deck(52) as cardsShared means that every SUB in the program can access values of Order(j), and Deck(j). The first card dealt will be Deck(Order(1)). The definition of type says that its value is Deck(Order(1)).value and its suit is Deck(Order(1)).suit.
DIM Shared Order(52)