Class Library for Shuffling a deck of cards

  • 7 years ago

    Hi  all,

    I am looking for sample VB.Net codes for deck of cards. Yes, I am looking for a solution.

    The question:

    " A class modules that will simulate shufling a deck of cards. The class module, when initialized, should create an array to store a deck of 52 playing cards. Create a method named Shuffle to shuffle the deck of cards, as well as another method to deal each card from the deck of cards. The latter method, named DealCard, should deal the next card off the deck. This form should contain a list box that displays each card in the deck after they have been shuffled. Will need a button that, when clicked,will shuffle the deck of cards.

    • In the class module, declare an array of structures. This should contain elements, each representing a card in the deck. The structure should have two members: one representing the card (Ace, 2, 3, 4, ...), and a second member representing the suit of the card. In the new procedure, store the cards in the array.
    • To shuffle the cards, all the Randomize function to seed the random number genrator. In random order,copy the content of the first array to a second array.
    • The DealCard method should deal the cards from the second array".

    I am looking for sample codes of deck of cards. Does anyone has codes for this?  I would appreciate it. Thank you.

    Regena

  • 7 years ago

    Sorry, I don't know of any sample projects to point you to.  You might want to search the internet  for sample projects pertaining to card games such as blackjack, or poker or anything with cards.  Those types of programs are sure to have a shuffling routine.

    If you have any specific questions I'd be happy to help.

  • 7 years ago

    Hi,

    Thanks. I did search many times and I could not find one. I will keep searching.

    Thanks lots,

    Gena

  • 7 years ago

    Well, I did another quick search and wasn't able to find a very good example either.  Honestly though I think you'd be better off just trying to write the class.  You may not find a helpfull example and even if you do the time wasted finding it could have been better spent writing the code.  Even with mistakes (which are a great learning tool) you'll be better off time wise just sitting down and doing it.  The information on how to go about it is right there in your first post.  Try breaking that information down into parts and figure out what you need to accomplish.  If you don't know how to do something like make a structure just ask or do some research, but the instructions are pretty clear.  Good luck and if you get stuck let me know.  I'll be happy to help.

  • 7 years ago

    Not sure if this will be of any use but

    http://msdn2.microsoft.com/en-us/vbasic/ms789080.aspx

    this is the card game starter kit from msdn

    mick

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth