This tutorial is designed to run in the VB.NET environment since it is probably one of the easier languages to read. It is easily adaptable to just about any other language, by adding semicolons and/or the format of the procedures and commands. I will randomize an array of strings representing a standard deck of cards since it is an example everyone can relate to, however it will work for any array of objects. I have used the procedure to randomize pictures in an album and buttons for various games. An "Object oriented" approach has been used in order to provide portability of the code. 2 procedures have been written: the shuffle( ) procedure and the swap( ) procedure. there is also an initialization section in which the array is established prior to running the procedures and a call to the procedure. |