473,473 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how do you shuffle a deck of cards?

6 New Member
Using integer and modulus division, determine how a deck of 52 cards can be represented by randomly generating 52 number. Each number should have a numeric value and a suit (ex: 4 of clubs)
Dec 3 '15 #1
9 1268
Rabbit
12,516 Recognized Expert Moderator MVP
This isn't a code writing service, what have you tried so far?
Dec 3 '15 #2
nc629
6 New Member
I've been on this project for weeks and I can't figure out anything. The only thing I can think of is assigning a string to every number and making the random number not repeat itself, but that doesn't include any division.
Dec 3 '15 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Here's a hint, if you integer divide a random number from 0-51 by 13 you get 0,1,2, or 3. 4 possible results for 4 possible suits. If you mod a random number from 0-51 by 4, you get a number from 0-12. 13 possible results for the 13 possible card ranks.
Dec 3 '15 #4
nc629
6 New Member
How do I make the numbers not repeat the same outcome?
Dec 3 '15 #5
Rabbit
12,516 Recognized Expert Moderator MVP
1) Generate a random number.
2) Check an array that stores the generated numbers to see if it's already in there.
3) If it's in there, go back to 1.
4) If it's not in there, put it in the array.
Dec 3 '15 #6
nc629
6 New Member
I got the card numbers and suits to work, but I still don't know how to use an array to make the numbers stop repeating.
Dec 15 '15 #7
Rabbit
12,516 Recognized Expert Moderator MVP
Each time you generated a card, you loop through the array to see if you already generated before hand.
Dec 15 '15 #8
nc629
6 New Member
How do I use an array?
Dec 16 '15 #9
Rabbit
12,516 Recognized Expert Moderator MVP
That's a very broad topic best suited for a class or tutorial. You can find any number of tutorials on google that will explain it greater detail than can be done in a forum. For example, this one: http://www.tutorialspoint.com/vb.net/vb.net_arrays.htm
Dec 16 '15 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: JC | last post by:
I am very new to programming and learning on my own. Why do I keep getting duplicate values using this code? I want to shuffle a deck of 52 cards. The logic seems right to me. Randomize For...
26
by: Radith | last post by:
Hi All, I have got this task which I cant get my head around: It asks how I would store information: I just want to get an opinion from the group: So here's the question: " You have been...
8
by: garyrowell | last post by:
I have been at this programme for hours trying to work out what is wrong. Any help would be very much appricated. Here is the breif I received. The program This week you are going to write three...
1
by: Vneha | last post by:
import java.util.*; public class Deck { public static int numSuits = 4; public static int numRanks = 13; public static int numCards = numSuits * numRanks; private Card...
8
by: l1nuxxx | last post by:
I have a file well call file.pl. It's a card sorting program. I need to create a lib fuction with part of the original file that shuffles the deck of cards. After it shuffles the first deck and deals...
1
by: dr4g0nk1ng | last post by:
i have this class that should create an array of cards public class DeckOfCards{ public Card card; public Card deck; DeckOfCards() { for (int s = 0; s < 3; s++)
21
by: blehhhhh | last post by:
So I'm trying to work on this problem of deck of cards wherein I have a few classes along with a tester class. Everything else is done. I just need help with implementing the methods properly. Here's...
2
by: amestrada113 | last post by:
public Deck() { cards=new Card; String suits = {"spades", "hearts", "clubs", "diamonds"}; int values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; for (int j=0; j<values.length;...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.