C++ :: Write A Program To Simulate Deck Of 52 Playing Cards

Oct 22, 2014

Write a program to simulate a deck of 52 playing cards.

Represent your deck as a 2D Array where the value in the cell is the position of the card in the deck. Represent the names for the suits and faces as an array of Strings.

Write an algorithm to shuffle the deck.

Display the deck. For Example:

1 Jack of Spades
2 Deuce of Diamonds
3 Three of Diamonds
4 King of Spades
5 Eight of Clubs
6 King of Diamonds
7 Six of Clubs
8 Six of Spades
9 Eight of Hearts

Deal two hands of five cards each. For Example:

****** HAND 1 ******
Jack of Spades
Three of Diamonds
Eight of Clubs
Six of Clubs
Eight of Hearts
...

Below is what I have so far. Dealing two hands and displaying it. How would I be able to do that?

#include <iostream>
#include <ctime>
#include <string>
using namespace std;
void shuffle(int[][2]);
int main()
{
int j,deck[52][2];

[Code]...

View 2 Replies


ADVERTISEMENT

C++ :: Write A Program To Simulate Deck Of 52 Playing Cards

Oct 26, 2014

Write a program to simulate a deck of 52 playing cards.

Represent your deck as a 2D Array where the value in the cell is the position of the card in the deck.

Represent the names for the suits and faces as an array of Strings.

#include "stdafx.h"
#include <iostream>
#include <string>

[Code].....

The problem: I am trying to connect the 1d arrays to the 2d arrays. Right now when I write: cout << deck[3][5] << endl; The output answer is 45. How do I populate the 2d array with the 1d arrays so that when I cout deck[3][5] I get it to say "Six of Spades"?

View 8 Replies View Related

C++ :: Deck Of Cards - No Output

Mar 5, 2013

I'm still new at C++, so my syntax might be a little off for getting the correct output. Currently, there are no compiler errors or warnings, but there is also no output when I run the program. It seems as if it is not calling something correctly maybe the .toString or perhaps my DeckOfCards constructor is a little off, either way, I can't seem to figure out why there is no output.

Anyways, here is my code:

Card.h
#ifndef CARD_H
#define CARD_H
#include <string>
using namespace std;
class Card {

[Code] ....

View 3 Replies View Related

C++ :: How To Fill Cards In Deck

Sep 9, 2013

Here is my source code i am trying to write a function (fillAll) to fill all 52 cards in a deck and i would like to use my data struct for the function and make Deck one of my parameters.

enum suit{HEARTS, CLUBS, DIAMONDS, SPADES};
enum face{TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE};
struct Card{
suit suitType;
face faceType;

[Code] .....

View 10 Replies View Related

C++ :: How To Make Standard Deck Of Cards

Feb 6, 2014

How to make a standard deck of cards and being able to shuffle and distribute the cards. I have made an array to store each card and I can display them but I assigned them all in order according to the suit and rank. Is this a viable way to do it if I intend to have a shuffle effect? Or should I create an array, randomly generate card, check for duplicates, then put them in the array, then display the array? Each card is a structure with two void pointer members for suit and rank.

View 1 Replies View Related

C :: Dealing A Deck Of Cards Using Structs?

Sep 9, 2013

I have a deck of 108 cards inside a 2D array and want to deal these card by 7 to 4 player. Each player had a id. The player and id are stored in a file while i've read in array each. Now I have to deal the cards.

Code:

struct card{
char color;
int rank;
char action[24];
char location[108]; Code: struct players{char name[10];
int id[5];
char hand;
};

View 2 Replies View Related

C++ :: Simple Playing Card Deck Creator And Shuffler

Aug 10, 2014

This is a playing card deck creator and shuffler i made yesterday. It is very simple now, but i believe that it could easily be implemented into a card game program of some sort.

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define STANDARD_DECK 52

[Code] .....

View 1 Replies View Related

C/C++ :: Shuffled Deck Of Cards - Corrupt Stack Around Variable

May 21, 2014

I am writing a console application that creates a shuffled deck of cards using pointers and arrays, but I get the error "Run-Time Check Failure #2 - Stack around the variable 'deck' was corrupted" What's the stack? What does this mean and what did I do to cause the stack to be corrupt?

#define _CRT_SECURE_NO_WARNINGS
#include "stdlib.h"
#include "time.h"
#include "stdio.h"
#include "conio.h"
typedef struct card{
int cval;

[Code] .....

View 8 Replies View Related

C/C++ :: Deal 2 Hands Of Cards - Print Deck After Dealing

Apr 2, 2014

My assignment is to create a program to print a deck of 52 cards, shuffle it, deal 2 hands of 5 cards, then print the deck after dealing the 2 hands with the cards that were dealt removed. this is my code so far...

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DECK_SIZE 52
void init_deck( int deck[] , int size ) ;
void shuffle_deck( int deck[] , int size ) ;

[Code] ....

I am having trouble dealing 2 random hands and how to print the deck with the cards removed.

View 3 Replies View Related

C++ :: Create Array Of Playing Cards / Assign Values And Suits Then Shuffle The Array

Nov 24, 2014

I got this program to create an array of playing cards and assign the values and suits and shuffle the array. I'm at the point where I need to output the cards but I need to burn the first card by making it output "**" instead of the card. my cards[] is a constant so I can's assign the first card as such.

void showCards(const int cards[], int numCards, bool hideFirstCard) {
if (cards[0]) {
hideFirstCard=true;
cards[0] = '**';
} for(int a = 0; a <= numCards; a++) {
cout >> showCard(cards[a]);
} }

View 1 Replies View Related

C++ :: Program To Simulate Coin Toss

Nov 14, 2013

Write a program that simulates coin tossing. For each toss of the coin, the program should print Heads or Tails. Let the program toss the coin 100 times and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads. [Note: If the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time.]

View 7 Replies View Related

C++ :: Program To Simulate Customers Lining Up To Buy Tickets For Some Event

Oct 17, 2013

Create a line class using a linked list that acts as a queue (first in, first out) both enqueue and dequeue. Complete the line class so that customers can be added or removed from the line. Implement the line as a linked list of customer objects that you have developed yourself or use the vector class.

View 2 Replies View Related

C++ :: Pointer Arrays - Program To Simulate Squares Most Landed On

Jun 8, 2014

I have not been using pointers that long i most of my stuff has not needed them but now they do i need to learn how to use them more. I'm writing a program that simulates the squares most landed on(for fun) and i cant get a method to work because of an array pointer.

The error is no matching function for call to 'GameLoop::Loop(int, int (*)[4])'

Here is the latest version of the code. I've been editing a lot of things so there might be some stupid errors but I've tring everything.

rolling.h and rolling.cpp are just some dice function they are working perfect.

main.cpp

#include <iostream>
#include "Rolling.h"
#include "GameLoop.h"
Rolling Roll;
GameLoop Game;

[Code] ....

View 2 Replies View Related

C++ :: Program And Simulate 2 Floor Lift Control System?

Apr 28, 2014

I need to program and simulate a 2 floor lift control system. How to do that ? I need to design its program only.

View 1 Replies View Related

C++ :: Program That Simulate Card Game - Array Manipulation

Apr 26, 2013

Consider a program that simulates a card game, with multiple player hands and a deck to draw from. Each hand can use an array to represent the cards it contains; sometimes it is useful to also declare an additional variable for each hand (or deck) indicating exactly how many cards are present.

1) Describe a simple function that would manipulate both the array representing a hand and the number indicating the size of the hand.

2) Describe a simple function that might be able to manipulate the array without referring to the hand size variable at all.

3) Generally, if the array was passed as a parameter to a function, how often would the hand size be included as a parameter?

View 2 Replies View Related

C :: Program To Simulate Taxi Rank Implemented As Queue Via Array - Linked List

Mar 26, 2013

I have an assignment where i am required to code up in C, a program to simulate a taxi rank that is implemented as a queue via an array that can hold up to a maximum of six taxis.When a taxi arrives, it joins the rear of the queue. When a taxi departs, the first taxi in the rank is used and its departure is logged.A "rolling menu" comprising integer codes as specified below is used until 0 is entered to exit the simulation. I've done this stage but now the next stage is asking me to implement the queue as a linked list. what the difference is between an array and a linked list and what is a linked list?

View 2 Replies View Related

C :: How To Initialize Deck Of Card

Mar 25, 2014

The deck of cards so it is populated with all 52 cards. Once you have populated the deck, you need to shuffle the deck. Here is a simple algorithm you might consider for this purpose:

For each card up to the middle of the deck generate a random number modulus the size of the deck, swap the current card with the card at that location done

To implement this requirement you need to implement and use the following functions:

void initDeck(Card * deck);

View 4 Replies View Related

C++ :: Music Not Playing SDL

Jan 24, 2013

The music that I want to plays not run :( Theoretically all arguments are well, but I don't understand why not works.

if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) < 0) {
cout << "Error inesperado";
return 0;
}
Mix_Init(0);
Mix_Music *musica = NULL;
musica = Mix_LoadMUS("pixeluniverse.wav");
if (!Mix_PlayMusic(musica, -1)) {
cout << "Error inesperado";
}
...

View 12 Replies View Related

C/C++ :: Sorting Deck From File With Merge Sort

Nov 27, 2014

I'm trying to sort a deck from file with merge sort.I have all my code working except merge sort function .

#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int temp;
int br = 1;

[Code] ....

View 10 Replies View Related

C++ :: Playing Audio File?

Jan 5, 2013

i have a audio file that i want to play via C+.

View 4 Replies View Related

C/C++ :: Audio Playing With Irrklang?

Apr 4, 2014

I tried playing audio using irrKlang in openGL.But i ended up with some problems.

I have attach my source file and also my output file here.

View 2 Replies View Related

C++ :: API For Playing Sounds On Console Application

Aug 8, 2013

I'm thinking of making a horror text-based game, which would use sounds, if you could also tell me of an API to display images in an alternate window that would be nice.

View 6 Replies View Related

C++ :: Quiz Game - Playing Video In One Round?

Apr 9, 2014

I am making a game of quiz and i want to play a small clip in one of the rounds, but i dont know how to do it in c++ ....

View 3 Replies View Related

C# :: Playing Video Without Windows Media Player?

Mar 26, 2014

I try to play a video I i don't know how.. I searched and i found some tips and articles, but all of it if about Windows Media Player. It's fine, but i need to play something lika an intro an i don't wanna show all that buttons of WMP.. I tried to hide it but no change.

View 2 Replies View Related

Visual C++ :: Cannot Get The Sound To Stop Playing CDA File

Apr 26, 2013

I can not get the sound to stop playing a cda file with MCI_CLOSE. This code works with wav and mpg and avi files.

LONG WindowProc() {
switch (msg) {
case WM_COMMAND:
if (wParam == IDC_PLAY) {
//A CDA File
SendMessage(m_hwMCI,MCIWNDM_OPENA,0,(LPARAM)&chFile);

[Code] .....

View 1 Replies View Related

C++ :: How To Shuffle A Vector (cards)

Mar 2, 2014

I am trying to write a sub-program that takes a deck of 52 cards and will shuffle it up using this algorithm:

Start with n=51
Repeatedly:
Generate a random integer between 0 and n. Call it i.
Swap card i and card n in the deck.
Decrease n by 1

However the code that I've written,

vector<int> shuffleDeck(vector<int> deckVector)//deckVector is the original deck in order
{
int temp, n, i, s;
n = 51;

[Code].....

when I output the new vector, only produces this output(note- it is a random number every time, but it just repeats over and over):

8 8 8 8 8 8 8 8 0 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
8 8 8 8 8 8 8 8 8 8 8 8

or:

22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 0 22 22 22 22
22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved