Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1107909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:00:12+00:00 2026-05-17T02:00:12+00:00

Making an uno game for a project. all 108 cards are located in a

  • 0

Making an uno game for a project.

all 108 cards are located in a filled array named cardDeck[108]

the start function pulls 7 cards at random and fills the players hand by adding
them to an array called playerHand[]

I need help on this please.

1) I don’t know how to make the cards dissappear out of the cardDeck array when they are pulled into playerHand[].

2) I also don’t know how to create something that will count the non-null values in the cardDeck array so it will display the total number of cards left in the deck after both players draw cards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:00:13+00:00Added an answer on May 17, 2026 at 2:00 am
    #include <cstdlib>
    #include <vector>
    #include <algorithm>
    using namespace std;
    

    Make the deck a vector.

    vector<Card> deck_;
    

    Insert each card in to the deck.

    deck_.push_back(Yellow0);
    deck_.push_back(WildDraw4);
    

    Shuffle the deck

    srand((unsigned)time(0));
    random_shuffle(deck_.begin(), deck_.end());
    

    Take cards out of the deck & put them in the player’s hand.

    vector<Card> player_hand_;
    for( size_t i = 0; i < 7; ++i )
    {
      player_hand_.push_back(deck_[0]);
      deck_.erase(deck_.begin());
    }
    

    EDIT:

    Per a request in the comments below, I’ll explain why I believe there should be multiple vectors of stateless cards rather than a single vector of stateful cards.

    One of the ideals that OOP tries to approach is to model the real world as closely as possible. Now obviously a vector is not OOP, but the cards contained therein theoretically can be. And while it certainly can’t be achieved perfectly in many cases, or should even be attempted to be perfectly achieved in as many cases, attempting to model software components after the real world IMO transcends any particular programming paradigm.

    So consider the Uno cards. An Uno card has a couple of different properties. They have a rank (0-9) and they have a suit (red, blue, yellow, green). There are also a few cards that have special meaning and have neither suit nor rank (WildDraw4, Wild, Draw2, Skip, reverse).

    So if we were to model an Uno card in C++, what would it look like? Uno cards don’t change once they are printed. A yellow 2 will never be a green 5 or a Wild Draw 4, for example. If you take a green7 out of the box and hand it to your friend, it’s still a green7. It’s now in your friend’s hand, but that’s not something that’s changed about the card. Rather, what’s changed is your friend’s hand. Instead of being empty, it now holds a Green 7 Uno card.

    In the game of Uno, each player is dealt 7 cards. There is one card placed face-up that becomes the discard pile, and the remaining cards are placed face-down forming the draw pile. When you move a card from the draw pile to a player’s hand, the card still hasn’t changed even though it’s location has. But don’t get hung up on human language. “It’s location” doesn’t imply that the location of the card is a property of the card. But when you move the card, something has changed — the states of the draw pile and the player’s hand.

    So we end up with a vector for the draw pile, another for the discard pile, and one vector for each player, representing their hand.

    This design is easy to understand by a maintenance programmer, easy to extend, and easy to develop the first time. Because it is simple, it is also not especially prone to defects. After all, which is more likely to break down — a skateboard or the Space Shuttle?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an iPhone cards game where each use has a deck of cards,
Making a new shooter game here in the vein of Galaga (my fav shooter
Im making slide show with jquery How i can set interval between two function
Does making a class field volatile prevent all memory visibility issues with it in
Making the transition from Vim to gVim, I would like to disable all toolbars
Making a ternary logic table, and I would like to make my own function
Making a game with OpenGL/GLUT and C++. I've heard the easiest way to manage
Making game of life I need to a have a grid that is 30x20
making a call to a web service method with nusoap returns an error array(3)
im making a platform type of game. I made my main character a rectangle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.