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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:07:19+00:00 2026-06-17T06:07:19+00:00

I wrongly worded my last question so I’m going to retry this. I am

  • 0

I wrongly worded my last question so I’m going to retry this. I am making a card game in java, and currently I have the code to print 4 random cards in an arraylist for x number of players. I am using slick 2d and currently have a menu and a play state. I currently have 2 variables connected to each card, a ranging from 0-3, and b ranging from 0-12.

How can I display an image in the play state that will relate back properly to these 2 variables? (ex. instead of displaying ace of spades, it displays a picture of the ace of spades)

Code:

Deck ()
{
    cards = new ArrayList < > ();
    for (int a = 0 ; a <= 3 ; a++)
    {
        for (int b = 0 ; b <= 12 ; b++)
        {
            cards.add (new Card (a, b));
        }
    }
}

This is the function to draw a card from a deck

public Card PlayerCardDraw ()
{
    Random generator = new Random ();
    int index = generator.nextInt (cards.size ());
    return cards.remove (index);
}

and this is the function that uses the above function to add a card to player 1’s hand. I made this to separate each player’s hand of cards.

public ArrayList <Card> p1Hand;
public ArrayList <Card> P1CardDraw ()
{

    p1Hand = new ArrayList < > ();
    p1Hand.add (PlayerCardDraw ());
    return p1Hand;
}

I mentioned I’m using slick 2d, so I assume I won’t have to post any of that code.

  • 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-06-17T06:07:20+00:00Added an answer on June 17, 2026 at 6:07 am

    If I were you, I would rewrite/append the Card class to attach an image on initialisation. Create an image in a common directory, and encode it a-bb.* for an example, and create a public image constant for that particular card. then it would be as simple as calling a simple getter to display the image.

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

Sidebar

Related Questions

I have an if statement currently written (wrongly) as: <%# Eval(AccumHolidays).ToString() != ? Eval(AccumHolidays).ToString()
I need someone to lead/guide me where have I code wrongly because I can't
I asked this question a couple days ago but I think I worded my
This question for cold fusion programmers, and will be probably asked by me wrongly,
This question originally asked (wrongly) what does | mean in Python, when the actual
I have a funny feeling I'm approaching this problem wrongly. Here's what I'm trying
sorry guys, asked a bit wrongly, here is the EDIT got a simple question,
Hei, i think order by is ordering things wrongly. Example code: static void Main()
//Edit: Really, nobody has any suggestions or thoughts on this? Have I asked the
I am getting duplicates of my array, and wrongly displayed cells in this method:

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.