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

  • Home
  • SEARCH
  • 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 4382400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:46:28+00:00 2026-05-21T12:46:28+00:00

I have been going crazy on this program im writing. My decks dont seem

  • 0

I have been going crazy on this program im writing. My decks dont seem to work and I have hunted for every tidbit of information but after 8 hours straight it still does not work =( Please help on pointing out where i need to work on better or how to go about coding it better.

package poker;

public class Deck {

private Card[] cards;

// deck constructor with initial array
public Deck() {
    Card[] x= new Card[52];
    int index = 0;
    for (int suit = 0; suit < 3; suit++) {
        for (int value = 1; value < 13; value++) {
            cards[index] = new Card(value, suit);
            index++;

        }

    }
}

// copy constructor with a shallow copy of the array
public Deck(Deck other) {
    Card[] c = new Card[52];

    int index = 0;
    for (int suit = 0; suit <= 3; suit++) {
        for (int value = 1; value <= 13; value++) {
            cards[index] = new Card(suit, value);
            index++;
        }

    }
}

// method for cards in any position
public Card getCardAt(int position) {
    if (position >= cards.length) {
        throw new IndexOutOfBoundsException("Values are out of bounds");
    } else {
        return cards[position];
    }
}

// number of cards left after each draw
public int getNumCards() {

    return cards.length;
}

// Randomized rearrangement of cards





//have no idea to go about this any further 
public void shuffle() {
    int temp=0;
    for (int row=0;row<cards.length;row++){
        int random = (int)(Math.random()*((cards.length-row)+1));
    Deck.this.cards[temp]= this.getCardAt(row);
    cards[row]=cards[random];
    cards[random]=cards[temp];
    } 
}
    //cutting of the cards
public void cut(int position) {
    //int temp = this.cards
}

// something to think about on dealing from taking the differences in
// dealing the cards
public Card[] deal(int numCards) {
    /* numCards = 5;
    for (int i = 0; i < numCards; i++) {

        numCards = cards.length - numCards;
    }
    return deal(numCards);*/
     {  
             numCards = this.getNumCards();  
            numCards ++;  

            return deal(5);
        }  

}

}

I tried to Junit test but i seem to suck at them but i tried

package poker;

import junit.framework.TestCase;

public class StudentTests extends TestCase {
public void testDeck() {
    int value=0;
    int suit = 0;
    Card[] x = new Card[52];
    //Card = new Card(getValue(), getSuit());

    assertTrue(getValue() == 1 && getSuit() == value);
    assertTrue(getValue() == 1 && getSuit() == suit);
    ;
}
public void testCopyConstructor(){

        int value = 0;
        int suit = 0;
        Card[] sc = new Card[52];
        //Card = new Card(getValue(), getSuit());

        assertTrue(getValue() == 1 && getSuit() == 0);

}
/* public void testShuffle()  
   {  
     Card[] sc = new Card[52];
     Card[] sc2 = new Card[52];
      assertTrue(sc==(sc2));  
       //shuffle method
      assertFalse(sc==(sc2));  

      //another shuffle method here
      //i have no idea 

      assertFalse(sc==(sc2));} */

private int getValue() {
    // TODO Auto-generated method stub
    return 1;
}

private int getSuit() {
    // TODO Auto-generated method stub
    return 0;
}
}
  • 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-21T12:46:29+00:00Added an answer on May 21, 2026 at 12:46 pm

    In your Deck constructor, initialize your cards member array as follows:

    public Deck()
    {
       cards = new Card[52];
    
       int index = 0;
    
       for (int suit = 0; suit <= 3; suit++)
       {
          for (int value = 1; value <= 13; value++)
          {
             cards[index] = new Card(value, suit);
             index++;
          }
       }
    }
    

    Also, your Deck copy constructor doesn’t do any actual copying.

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

Sidebar

Related Questions

I have been going crazy with binding a combobox to an enum typed property
This one had me going crazy for awhile. I have an app that was
I have been going crazy over a problem with my tab control. It has
I have been going through this tutorial on auto-populating boxes using jQuery and Ajax:
I have been going back and forth between C# and Java for the last
I've switched over to a Mac recently and, although things have been going quite
I have been tasked with going through a number of ColdFusion sites that have
I have been using C# for a while now, and going back to C++
I've been going stir crazy trying to install the ruby mysql gem here, and
I currently have this line of code which has been working for the past

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.