| | |
need help creating a "stack" of cards
![]() |
•
•
Join Date: Mar 2005
Posts: 91
Reputation:
Solved Threads: 1
i need some help on this, im making a blackjack game and i need to make a stack of cards and i dont know what to do so just get me started is all im really askin for.
here is what i have so far
here is what i have so far
C++ Syntax (Toggle Plain Text)
#include <stack> #include <list> #include <iostream> #include <conio.h> #include <string> using namespace std; const DECKS = 8; enum suit { Clubs, Diamonds, Hearts, Spades}; enum value { Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King}; /****************************************************/ class Node { private: int data; Node* next; public: Node(); Node(int data); ~Node(){}; Node(Node& node); Node& operator = (Node& node); int getData() {return data;}; Node* getNext() {return next;}; void setData(int data) { this->data = data;}; void setNext(Node* next) { this->next = next;}; }; Node::Node() { data = 0; next = NULL; } Node::Node(int data) { this->data = data; next = NULL; } Node::Node(Node& node) { this->data = node.data; next = NULL; } Node& Node::operator= (Node& node) { this->data = node.data; next = NULL; return *this; } /**************************************************************/ /**************************************************************/ struct Card { stack<Card> deck; static int counters[52 * DECKS]; int jack, queen, king; int ace(); Card(); ~Card(); Card (Card& card); Card operator = (Card& card); }; Card::Card() { jack = 10; queen = 10; king = 10; } int ace() { int choice; cout << "do you want your Ace/s to be a 1 or an 11?" << endl; cin >> choice; return choice; } /**************************************************************/ class Player { private: static int players; int val; // sum of all the cards public: Player(); ~Player(); Player (const Player& player); int getSize() {return size}; }; Player::Player() { val = 0; } class Playerlist { private: int size; //number of players Player* player; // array public: Playerlist(); ~Playerlist(); Playerlist (const Playerlist& playerlist); int getSize() {return size;} Player* getPlayer(int index) {return &player[index];} }; Playerlist::Playerlist() { player = NULL; cout << "How many players will be playing? " << endl; cout << "* Number of players should not exceed the cubic dimensions * " << endl; cin >> size; player = new Player [size]; } Playerlist::~Playerlist() { delete [] player; } Playerlist::Playerlist (const Playerlist& playerlist) { size = playerlist.size; player = new Player [size]; for(int s = 0; s < size; s++) player[s] = playerlist.player[s]; } /***************************************************************/ int Player::players = 1; //static players void main() { Playerlist p; Card c; }
What exactly are you going to do with your deck of cards? I presume you'll have some common routines such as "shuffle", "cut deck", etc. but different card games use different rules. A totally generic deck might not be possible, or even desirable. I suggest you decide first which games you want to simulate, then you'll get a much clearer idea of what to do. Not all card games treat the deck as a stack either. some card games treat it more like a queue, others involve a random draw from the middle - keep that in mind when you decide what sort of container to keep the cards in.
•
•
Join Date: Mar 2005
Posts: 91
Reputation:
Solved Threads: 1
its goin to be casino like but im not goin to follow all the ruled there will be 8 decks in the stack of cards and u just take a card from the top of the deck after its shuffled. im not goin to bother with cutting the eck though
i dont think my code actually works i got a few error i think still with the enumerator types but i dont know how to start the stack of cards. i have to do that to basically do the rest of the program so i know what everything is
i dont think my code actually works i got a few error i think still with the enumerator types but i dont know how to start the stack of cards. i have to do that to basically do the rest of the program so i know what everything is
It sounds like you're trying to do a bit too much at once - start out with getting the program to compile with just one card.. then get it to compile with a deck of cards... then take small steps adding more functionality as yóú go.
Personally i'd change the Card structure. To my mind, the only 2 bits of information a playing card holds are its suit and its rank - a card doesn't hold information about the rest of the deck.
The enums are definitely erroneous, you can't begin an identifier with a number, so you'll need to use
Personally i'd change the Card structure. To my mind, the only 2 bits of information a playing card holds are its suit and its rank - a card doesn't hold information about the rest of the deck.
The enums are definitely erroneous, you can't begin an identifier with a number, so you'll need to use
ace, two, three, four, five etc, instead. ![]() |
Similar Threads
- help Creating "input-fields" (Visual Basic 4 / 5 / 6)
- Help needed In creating application to make business cards (Java)
Other Threads in the C++ Forum
- Previous Thread: Array of pointers
- Next Thread: been at this for 5 hrs now and can't figure it out please help...
Views: 1378 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C++
6 algorithm array arrays assignment beginner binary c++ c/c++ calculator char class classes code compile compiler constructor conversion convert count delete desktop dll dynamic encryption error file files fstream function functions game givemetehcodez graph graphics gui homework http iamthwee input int integer lazy lib linker list loop looping loops math matrix memory newbie number numbers object objects opengl output parameter pointer pointers problem program programming project python qt random read reading recursion recursive reference server sort sorting spoonfeeding string strings struct student studio template templates text time tree undefined variable vc++ vector video visual visualstudio win32 window windows winsock wxwidgets






