16.15. Card Shuffling and Dealing Simulation

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.

Figure 16.16. Card class.
					1
					' Fig. 16.16: Card.vb
					2
					' Stores suit and face information on each card.
					3
					Public Class Card ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.