For the guys who helped on the card.java file I did thnaks a lot I got that done. I have now moved onto the next part of that and have to complete this skeleton file.
this is the spec for this file.

This class has two attributes: an array of Cards holding the 52 cards of the deck; an int that holds the number of cards in the deck, (this attribute is not used in this homework but may be used later)

The class also has a void shuffle() method and a String toString() method

The skeleton class

/**
 * This class represents a deck of 52 playing cards.
 * 
 * @author Ian Bradley 
 * @version 6/2/07
 */
public class Deck
{
    // DECLARE THE ATTRIBUTES HERE
    private Card [] deck = COMPLETE;
    private int numberOfCards ;

    /**
     * Creates a deck of 52 playing cards
     * The deck is set up in the order SPADES, DIAMONDS, CLUBS,HEARTS
     */
    public Deck()
    {
        String [] suits = {"SPADES","DIAMONDS","CLUBS","HEARTS"};
        //FOR EACH SUIT
            //FOR EACH RANK
                //INSTANTIATE A  ELEMENT OF  deck AS A CARD
        numberOfCards = 52;
    }
    
    /**
     * shuffles the deck of cards.
     * 
     */
    public void shuffle()
    {
		Card temp;
		//loop through each card in the deck and swap it with some random card.
		FOR EACH CARD IN THE DECK
		{
			int rand = (int)(Math.random()*52);
			//TAKE THE CURRENT CARD...
			//AND SWAP IT WITH THE RAND CARD...
			
		}
	}  
   
    /**
     * Returns a representation of the deck as a string
     * one card per line
     * 
     * @return     the deck as a String
     */
    public String toString()
    {
       String deckString = "";
       //BUILD THE STRING
          
       return deckString;
    }
}

Okay so I have started doing this and keep gettin errors on my array of objects. It keeps saying I need [] brackets.

here is my code.

class Deck
{
	
	Deck card[] = new Deck [52];
	card[0] ="SPADES Ace"; 		card[20] ="DIAMONDS 8"; 	card[39] = "HEARTS Ace"; 
    card[1] ="SPADES 2";   		card[21] ="DIAMONDS 9"; 	card[40] = "HEARTS 2";
    card[2] ="SPADES 3"; 		card[22] ="DIAMONDS 10"; 	card[41] = "HEARTS 3";
    card[3] ="SPADES 4"; 		card[23] ="DIAMONDS jack"; 	card[42] = "HEARTS 4";
    card[4] ="SPADES 5"; 		card[24] ="DIAMONDS queen"; card[43] = "HEARTS 5";
    card[5] ="SPADES 6"; 		card[25] ="DIAMONDS king"; 	card[44] = "HEARTS 6";
    card[6] ="SPADES 7"; 							 		card[45] = "HEARTS 7";
    card[7] ="SPADES 8";		card[26] ="CLUBS Ace"; 		card[46] = "HEARTS 8";
    card[8] ="SPADES 9"; 		card[27] ="CLUBS 2"; 		card[47] = "HEARTS 9";
    card[9] ="SPADES 10"; 		card[28] ="CLUBS 3"; 		card[48] = "HEARTS 10";
    card[10] ="SPADES jack"; 	card[29] ="CLUBS 4"; 		card[59] = "HEARTS jack";
    card[11] ="SPADES queen"; 	card[30] ="CLUBS 5"; 		card[50] = "HEARTS queen";
    card[12] ="SPADES king"; 	card[31] ="CLUBS 6"; 		card[51] = "HEARTS king";
    card[13] ="DIAMONDS Ace"; 	card[32] ="CLUBS 7"; 
    card[14] ="DIAMONDS 2"; 	card[33] ="CLUBS 8"; 
    card[15] ="DIAMONDS 3"; 	card[34] ="CLUBS 9"; 
    card[16] ="DIAMONDS 4"; 	card[35] ="CLUBS 10"; 
    card[17] ="DIAMONDS 5"; 	card[36] ="CLUBS jack"; 
    card[18] ="DIAMONDS 6"; 	card[37] ="CLUBS queen"; 
    card[19] ="DIAMONDS 7"; 	card[38] ="CLUBS king"; 
    int  numberOfCards = 52;

	public void shuffle()
    {
		Card temp;
		//loop through each card in the deck and swap it with some random card.
		//FOR EACH CARD IN THE DECK
		{
			int rand = (int)(Math.random()*52);
			//TAKE THE CURRENT CARD...
			//AND SWAP IT WITH THE RAND CARD...
			
		}
	}  

    public String toString()
    {
       String deckString = "";
       //BUILD THE STRING
          
       return deckString;
    }





}

I have tried to assign each card to a location in the array but I can't get it to work. any ideas?

You cannot place those assignments ("card[0] ="SPADES Ace";") directly in the class body like that. Additionally, you are not using the template that was provided. You have declared card[] as an array of Deck, when the assignment declares deck[] an array of Card.

It also indicates that in the constructor, you should loop through a suits[] and ranks[] array to create a new Card object for each card in the deck. Your current code is trying to assign a string to each array element where it should be assigning a Card object (once you declare the deck array properly).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.