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 7653349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:00:40+00:00 2026-05-31T12:00:40+00:00

I am trying to develop an UNO card game, and now I reach to

  • 0

I am trying to develop an UNO card game, and now I reach to a point where I need a data structure that can hold the whole deck, and then I can take pieces of it and distribute it among several places (The players, the discard pile, and the draw pile). The code would be something like this:

public class UnoGame
{
    public UnoGame()
    {
        SomeDataStructure<Card> unoDeck = generateUnoCards();
        List<Cards> player1 = unoDeck.get(7);
        List<Cards> player2 = unoDeck.get(7);
        List<Cards> discardPile = unoDeck.get(1);
        List<Cards> drawPile = unoDeck.getRest();
    }

    private static SomeDataStructure<Card> generateUnoCards()
    {
        SomeDataStructure<Card> cards = new SomeDataStructure<Card>(108);
        // Here we can create the proper cards and add them to the data structre
        Collections.shuffle(cards);
        return cards;
    }
}

So, it there any built-in data structure in Java that fits my requirements? Or should I implement my own data structure?

  • 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-31T12:00:41+00:00Added an answer on May 31, 2026 at 12:00 pm

    It’s not really clear why you need anything special. I would model it as per the real game: a stack for all the cards (using LinkedList<T> as the stack implementation), which you then take cards off to get a hand, and which is also used to fetch cards later. I would model each player with a separate class though… even if initially it just contains a List<Card> or something similar.

    List<Player> players = new ArrayList<Player>();
    LinkedList<Card> deck = createDeck(); // This should shuffle too
    for (int i = 0; i < playerCount; i++) {
        Player player = new Player();
        players.add(player);
        for (int j = 0; j < 7; j++) {
            player.addCard(deck.removeLast());
        }
    }
    LinkedList<Card> discards = new LinkedList<Card>();
    

    At every point, if you think about what would happen in the physical game, it should be reasonably easy.

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

Sidebar

Related Questions

I am trying to develop a BlackBerry application that will show data from an
I'm trying to develop a DHCP client application in java that can receive DHCP
I trying to develop a game for iPhone by using Cocos2d. I need 'DRAG'
We are trying to develop a widget that can be embedded by third parties
Im trying to develop service that starts by bootup receiver if the wifi or
im trying to develop an app for a win CE mobile device that downloads
I am trying to develop an application for my localhost on which I can
I am trying to develop the XMPP Gateway which can send/receive from standard XMPP
I am trying to develop a game and I was having issues managing the
trying to develop web form using jquery. all i need is to have several

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.