Example 2: Shuffling with Property Procedures

This example modifies the shuffle program once again, this time adding the following features:

  • A constructor method will initialize the deck of cards. That way, the class will work correctly even if the calling program forgets to call the InitializeDeck method.

  • A property procedure will replace the Public array intDeck. This ensures that the calling program doesn’t accidentally (or mischievously) modify the deck.

To make these changes, start Visual Studio .NET and then follow these directions:

  1. Create a new Windows Application project named shuffleclass2.

  2. Make sure all code and design windows are closed and then, in Windows Explorer, copy the Form1.vb and Deck.vb files from the shuffleclass folder to the ...

Get Faster Smarter Beginning Programming 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.