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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:12:02+00:00 2026-06-14T23:12:02+00:00

My deck create an array of Card objects, and it prints out successfully that

  • 0

My deck create an array of Card objects, and it prints out successfully that it is updated. I want to make a third class to implement the program: create a deck object, ask players how many card they want and then pass them out randomly. In the PlayingTable class at the bottom I try to create an instance of a deck and scan it to make all the information in the deck is there. It says I can’t scan a deck object because it’s not an array, and I’m not quite sure where to go from here….

Here’s my code for the two classes:

public class Card

{

    //Instance properties//
    private String cardNum; 
    private String cardSuit;

    //Instance Methods // 
    //Constructor, create an instance of card
    public Card( String num , String suit ) 
    {
        System.out.println( "Creating a card.");
        cardNum = num ;
        cardSuit = suit;    
    }       
     public void display()
     { 
    System.out.println("This card is a" + " "+ cardNum + cardSuit);
    }

}

public class Deck

{
// Instance properties//

 //Number of cards in a deck
 public static int numCards = 52; 
 private static Card [ ] deck= new Card [numCards];
 private static String [ ] cardValue = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" } ;
 private static String [ ] cardSuit = { " of Hearts" , " of Spades", " of Clubs", " of Diamonds" };

 //Instance methods and Constructor//
 /*public void Deck ( )
 {


 }*/

 public static void fillDeck ( )
 {

    int eachCard = 0 ;

    for ( int i = 0; i < cardValue.length ; i++ )
    {
     for ( int j = 0 ; j < cardSuit.length ; j++ )
        {

         deck[eachCard++] = new Card ( cardValue [i] , cardSuit [j] );

        }
     } 
 }

public static void getDeck ()
{
    for ( int i = 0; i < numCards ; i++ )
   {
    fillDeck();
    //System.out.println( " This is card" + i + " " + " of the deck" );
    deck[i].display();
    }
}   
public static void main (String [] args ) 
{ 
    getDeck();
}

}

public class PlayingTable
{
static Deck dealersDeck = new Deck();

    public static void main ( String [] args )
    {  

        for ( int i = 0 ; i < 52; i++)
        {
              System.out.println ( dealersDeck[i].getDeck());
        }

    }

}

  • 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-14T23:12:03+00:00Added an answer on June 14, 2026 at 11:12 pm

    Q: How do I display information form one class … [from] … another class?

    A: Provide public “getter” methods (or, if you’re programming #, “properties”) in the “other class”.

    Here’s a good tutorial on C# properties:

    • http://csharp.net-tutorials.com/classes/properties/#.UJ79KlZz2So

    And a discussion on Java “getter/setter” methods:

    • http://www.daniweb.com/software-development/java/threads/13283/getset-methods-in-java

    Finally, here’s a discussion on OO “encapsulation”, an issue that actually transcends “properties”, “getter/setter methods” … AND … “displaying information in one class from another”:

    • http://en.wikipedia.org/wiki/Encapsulation_%28object-oriented_programming%29
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make an array with every card in the deck, so it
I would like to create a card-deck class in MatLAB. This is my first
Imagine that I have a nice Deck class, in the best OO fashion. It
I have a class 'Deck', that creates an ArrayList called deck. I'm trying to
I'm trying to create a deck of cards for my homework. Code is posted
Now I am trying to design a class for a deck of cards. I
I'm making an app for a custom Tarot deck that should be able to
I have several objects set up in Core Data, one of which is Deck
I have just had a brain block, I have a Deck object and want
I am working on a program (learning C#) that creates a object (Card) and

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.