June 2006
Intermediate to advanced
1344 pages
42h 52m
English
In this section, we use random-number generation to develop a program that simulates card shuffling and dealing. These techniques can form the basis of programs that implement specific card games.
Class Card (Fig. 16.16) contains two String instance variables—face and suit—that store references to the face value and suit name of a specific card. The constructor for the class receives two Strings that it uses to initialize face and suit. Method ToString (lines 12–14) creates a String consisting of the face of the card and the suit of the card to identify the card when it is dealt.
1 ' Fig. 16.16: Card.vb 2 ' Stores suit and face information on each card. 3 Public Class Card ... |
Read now
Unlock full access