Card game

minor errors

Page 1 of 1

6 Replies - 2251 Views - Last Post: 26 April 2009 - 07:53 PM Rate Topic: -----

#1 swim_fan08  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 302
  • Joined: 19-February 09

Card game

Post icon  Posted 24 April 2009 - 02:52 PM

I've been working on this card game for awhile, but I still get minor errors and not too sure how to fix them. I would appreciate it if someone were to help me. I've tried to fix these errors and find out what they mean, but I just seem to be making things worse in my program. :/

import java.util.*;
		import java.util.Random;

				public class DeckOfCards
				{
					private Card deck[];
					private final int TOTAL = 52;
					private int SWAPS=999999;
					private Random randomCard;
					private int currentCard=0;
					private int cardsUsed;
					private int cardReset=0;
					private int cardsDealt;


					//------------------------------------------
					//Constructor (Instantiates a deck)
					//Cards are unshuffled
					//------------------------------------------

					public DeckOfCards ()
					{


							String face[] = { "Ace", "Deuce", "Three", "Four", "Five", "Six",
							 "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
							  String suit[] = { "Hearts", "Diamonds", "Clubs", "Spades" };

							  deck = new Card[TOTAL];

							  currentCard = 0;

							  randomCard = new Random();

									for ( int index = 0; index<52; index++ )
									{

							deck[index ] = new Card ( face[ index % 13 ], suit[ index %4 ] );

   							}
   							cardReset=0;
						}





						   //-------------------------------------
						   //Shuffle the deck of 52 cards.
						   //-------------------------------------

						  public void shuffle()
   							{
								 currentCard= 0;
								 int card2;
								 int card1;


								   for ( int firstCard = 0; firstCard < SWAPS; firstCard++ )
								   {
									   card2 =  randomCard.nextInt( TOTAL );


									 		 Card temp = deck[card1];
											  deck[ card1 ] = deck[ card2 ];
											  deck[ card2 ] = temp;
								   }
							   }


							   //----------------------------
							   //Deals a card from the deck
							   	//----------------------------
							   		public Card dealCard()
							   		{

							   			if (cardsDealt == 52)
							   			shuffle();
							   			cardsDealt++;
										return deck[cardsDealt - 1];
									}

							//---------------------------
							//Cards left in the deck
							//---------------------------
							public int cardsLeft()
							{

						return 52 - cardsDealt;
						}
					}

Error:
cannot find symbol
symbol : constructor Card(java.lang.String,java.lang.String)
location: class Card
deck[index ] = new Card ( face[ index % 13 ], suit[ index %4 ] );
-Do I need to initiate a constructor?

import javax.swing.*;
import java.util.Random;


public class DeckOfCardsDriver
{
	//----------------------------------------------------
	//Main method that creates a new DeckofCards, shuffles
	//the deck, and then deals two five-card playing hands
	//for a game of poker.
	//----------------------------------------------------
	public static void main (String[] args)
	{

		DeckOfCards cards = new DeckOfCards ();

		DeckOfCards.shuffle();
		DeckOfCards.dealCard();

		  //------------------------------
		 // deals and print two five-cards
		 //-------------------------------
			DeckOfCards cards = new DeckOfCards [10];

				for(int index = 0; i<cards.length; index++)
				{
				System.out.println(cards[index].getFace() + " of " + cards[index].getSuitName());

				System.out.println();
		}
	}
}



Errors:
java:24: non-static method shuffle() cannot be referenced from a static context
DeckOfCards.shuffle();

java:25: non-static method dealCard() cannot be referenced from a static context
DeckOfCards.dealCard();

java:30: cards is already defined in main(java.lang.String[])
DeckOfCards cards = new DeckOfCards [10];

java:30: incompatible types
found : DeckOfCards[]
required: DeckOfCards
DeckOfCards cards = new DeckOfCards [10];

java:32: cannot find symbol
symbol : variable i
location: class DeckOfCardsDriver
for(int index = 0; i<cards.length; index++)

java:32: cannot find symbol
symbol : variable length
location: class DeckOfCards
for(int index = 0; i<cards.length; index++)

java:34: array required, but DeckOfCards found
System.out.println(cards[index].getFace() + " of " + cards[index].getSuitName());

java:34: array required, but DeckOfCards found
System.out.println(cards[index].getFace() + " of " + cards[index].getSuitName());

DeckOfCards.java:44: cannot find symbol
symbol : constructor Card(java.lang.String,java.lang.String)
location: class Card
deck[index ] = new Card ( face[ index % 13 ], suit[ index %4 ] );

public class Card
{
   public final static int ACE   = 1;
   public final static int TWO   = 2;
   public final static int THREE = 3;
   public final static int FOUR  = 4;
   public final static int FIVE  = 5;
   public final static int SIX   = 6;
   public final static int SEVEN = 7;
   public final static int EIGHT = 8;
   public final static int NINE  = 9;
   public final static int TEN   = 10;
   public final static int JACK  = 11;
   public final static int QUEEN = 12;
   public final static int KING  = 13;

   public final static int CLUBS	= 1;
   public final static int DIAMONDS = 2;
   public final static int HEARTS   = 3;
   public final static int SPADES   = 4;

   private final static int NUM_FACES = 13;
   private final static int NUM_SUITS = 4;

   private int face, suit;
   private String faceName, suitName;

   //-----------------------------------------------------------------
   //  Creates a random card.
   //-----------------------------------------------------------------
   public Card ()
   {
	  face = (int) (Math.random() * NUM_FACES) + 1;
	  setFaceName();

	  suit = (int) (Math.random() * NUM_SUITS) + 1;
	  setSuitName();
   }

   //-----------------------------------------------------------------
   //  Creates a card of the specified suit and face value.
   //-----------------------------------------------------------------
   public Card (int faceValue, int suitValue)
   {
	  face = faceValue;
	  setFaceName();

	  suit = suitValue;
	  setSuitName();
   }

   //-----------------------------------------------------------------
   //  Sets the string representation of the face using its stored
   //  numeric value.
   //-----------------------------------------------------------------
   private void setFaceName()
   {
	  switch (face)
	  {
		 case ACE:
			faceName = "Ace";
			break;
		 case TWO:
			faceName = "Two";
			break;
		 case THREE:
			faceName = "Three";
			break;
		 case FOUR:
			faceName = "Four";
			break;
		 case FIVE:
			faceName = "Five";
			break;
		 case SIX:
			faceName = "Six";
			break;
		 case SEVEN:
			faceName = "Seven";
			break;
		 case EIGHT:
			faceName = "Eight";
			break;
		 case NINE:
			faceName = "Nine";
			break;
		 case TEN:
			faceName = "Ten";
			break;
		 case JACK:
			faceName = "Jack";
			break;
		 case QUEEN:
			faceName = "Queen";
			break;
		 case KING:
			faceName = "King";
			break;
	  }
   }

   //-----------------------------------------------------------------
   //  Sets the string representation of the suit using its stored
   //  numeric value.
   //-----------------------------------------------------------------
   private void setSuitName()
   {
	  switch (suit)
	  {
		 case CLUBS:
			suitName = "Clubs";
			break;
		 case DIAMONDS:
			suitName = "Diamonds";
			break;
		 case HEARTS:
			suitName = "Hearts";
			break;
		 case SPADES:
			suitName = "Spades";
			break;
	  }
   }

   //-----------------------------------------------------------------
   //  Determines if this card is higher than the passed card. The
   //  second parameter determines if aces should be considered high
   //  (beats a King) or low (lowest of all faces).  Uses the suit
   //  if both cards have the same face.
   //-----------------------------------------------------------------
   public boolean isHigherThan (Card card2, boolean aceHigh)
   {
	  boolean result = false;

	  if (face == card2.getFace())
	  {
		 if (suit > card2.getSuit())
			result = true;
	  }
	  else
	  {
		 if (aceHigh && face == ACE)
			result = true;
		 else
			if (face > card2.getFace())
			   result = true;
	  }

	  return result;
   }

   //-----------------------------------------------------------------
   //  Determines if this card is higher than the passed card,
   //  assuming that aces should be considered high.
   //-----------------------------------------------------------------
   public boolean isHigherThan (Card card2)
   {
	  return isHigherThan (card2, true);
   }

   //-----------------------------------------------------------------
   //  Returns the face (numeric value) of this card.
   //-----------------------------------------------------------------
   public int getFace ()
   {
	  return face;
   }

   //-----------------------------------------------------------------
   //  Returns the suit (numeric value) of this card.
   //-----------------------------------------------------------------
   public int getSuit ()
   {
	  return suit;
   }

   //-----------------------------------------------------------------
   //  Returns the face (string value) of this card.
   //-----------------------------------------------------------------
   public String getFaceName ()
   {
	  return faceName;
   }

   //-----------------------------------------------------------------
   //  Returns the suit (string value) of this card.
   //-----------------------------------------------------------------
   public String getSuitName ()
   {
	  return suitName;
   }

   //-----------------------------------------------------------------
   //  Returns the string representation of this card, including
   //  both face and suit.
   //-----------------------------------------------------------------
   public String toString ()
   {
	  return faceName + " of " + suitName;
   }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Card game

#2 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Card game

Posted 24 April 2009 - 03:08 PM

Ok, lets see here.

1. -Do I need to initiate a constructor? In your code you use a String for both, you need to use ints not strings according to your constructor

2. DeckOfCards cards = new DeckOfCards [10]; Delete the 'DeckOfCards' it already knows it is one

3. DeckOfCards cards = new DeckOfCards [10]; add a '[]' after the type. DeckOfCards[] cards

4. for(int index = 0; i<cards.length; index++) Change i<cards.length to index <cards.length

5. deck[index ] = new Card ( face[ index % 13 ], suit[ index %4 ] ); Again you need to use 2 ints as a param not 2 Strings

Hope this helps!
Was This Post Helpful? 0
  • +
  • -

#3 swim_fan08  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 302
  • Joined: 19-February 09

Re: Card game

Posted 24 April 2009 - 05:56 PM

Made the changes and then got even more errors.

import java.util.*;
		import java.util.Random;

				public class DeckOfCards
				{
					private Card deck[];
					private final int TOTAL = 52;
					private int SWAPS=999999;
					private Random randomCard;
					private int currentCard=0;
					private int cardsUsed;
					private int cardReset=0;
					private int cardsDealt;


					//------------------------------------------
					//Constructor (Instantiates a deck)
					//Cards are unshuffled
					//------------------------------------------

					public DeckOfCards ()
					{
						int face;
						int suit;


							int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,
							int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };
							  int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;

							  deck = new Card[TOTAL];

							  currentCard = 0;

							  randomCard = new Random();

									for ( int index = 0; index<52; index++ )
									{

							deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );

   							}
   							cardReset=0;
						}





						   //-------------------------------------
						   //Shuffle the deck of 52 cards.
						   //-------------------------------------

						  public void shuffle()
   							{
								 currentCard= 0;
								 int card2;
								 int card1;


								   for ( int firstCard = 0; firstCard < SWAPS; firstCard++ )
								   {
									   card2 =  randomCard.nextInt( TOTAL );


									 		 Card temp = deck[card1];
											  deck[ card1 ] = deck[ card2 ];
											  deck[ card2 ] = temp;
								   }
							   }


							   //----------------------------
							   //Deals a card from the deck
							   	//----------------------------
							   		public Card dealCard()
							   		{

							   			if (cardsDealt == 52)
							   			shuffle();
							   			cardsDealt++;
										return deck[cardsDealt - 1];
									}

							//---------------------------
							//Cards left in the deck
							//---------------------------
							public int cardsLeft()
							{

						return 52 - cardsDealt;
						}
					}


import javax.swing.*;
import java.util.Random;


public class DeckOfCardsDriver
{
	//----------------------------------------------------
	//Main method that creates a new DeckofCards, shuffles
	//the deck, and then deals two five-card playing hands
	//for a game of poker.
	//----------------------------------------------------
	public static void main (String[] args)
	{

		DeckOfCards cards = new DeckOfCards ();

		DeckOfCards.shuffle();
		DeckOfCards.dealCard();

		  //------------------------------
		 // deals and print two five-cards
		 //-------------------------------
			DeckOfCards [] cards;

				for(int index = 0; index <cards.length; index++)
				{
				System.out.println(cards[index].getFace() + " of " + cards[index].getSuitName());

				System.out.println();
		}
	}
}



java:33: '.class' expected int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,

java:33: <identifier> expected
int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,

java:33: <identifier> expected
int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,

java:33: <identifier> expected
int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,

java:33: <identifier> expected
int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,
java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };

java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };

java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };

java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };

java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };

java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };
java:34: <identifier> expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };

C:\Documents and Settings\Owner\Desktop\DeckOfCards.java:34: ';' expected
int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };
java:35: ']' expected
int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;
^
java:35: <identifier> expected
int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;

java:35: <identifier> expected
int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;

java:35: <identifier> expected
int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;

java:35: <identifier> expected
int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;

java:46: '.class' expected
deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );

java:46: not a statement
deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );
^
java:46: ';' expected
deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );
^
java:46: ']' expected
deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );
java:46: not a statement
deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );

java:46: ';' expected
deck[index ] = new Card ( int face [ index % 13 ], int suit[ index %4 ] );
Was This Post Helpful? 0
  • +
  • -

#4 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Card game

Posted 24 April 2009 - 09:15 PM

int face[] = { int ACE; int TWO, int THREE, int FOUR, int FIVE,
							int SIX,int SEVEN, int EIGHT, int NINE, int TEN, int JACK, int QUEEN, int KING };
							  int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES;

Remove the int ACE on everyone of them no need to do that the array already knows it is an array of ints.
ex.
int[] cards = {ACE,TWO,THREE}; Dontneed to add the ints.

int suit[Card] = { int CLUBS, int DIAMONDS, int HEARTS , int SPADES; same with these, remove the int's, and add the close '}' before the semicolon
Was This Post Helpful? 0
  • +
  • -

#5 swim_fan08  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 302
  • Joined: 19-February 09

Re: Card game

Posted 26 April 2009 - 05:13 PM

I went back and edited my code again, but my compiler is still complaining about line 29 and 30 in my DeckOfCards file where I have ACE, TWO, THREE etc and the SPADES, HEARTS , and DIAMONDS etc.


import java.util.Random;
import java.util.*;

public class DeckOfCards
{
	private Card deck[];
	private int currentCard;
	private final int TOTAL=52;
	private Random randomCard;
	private int cardsDealt;
	private int cardsLeft;

	public DeckOfCards()
	{
		//------------------------------------------
		//Constructor (Instantiates a deck)
		//Cards are unshuffled
		//------------------------------------------
		int face;
		int suit;


	int [] cards ={ACE, TWO,THREE,FOUR, FIVE,SIX,SEVEN,EIGHT,NINE,TEN,JACK,QUEEN,KING};
	int suit[Card] ={CLUBS,DIAMONDS, HEARTS, SPADES};

	deck=new Card[TOTAL];
	currentCard=0;

	randomCard= new Random();

	for(int count=0; count < deck.length; count++)
	deck [count]=new Card(face[count%13], suit[count/13]);
	}


 //-------------------------------------
 //Shuffle the deck of 52 cards.
//-------------------------------------
	public void shuffle()
	{
		currentCard=0;
		int card2;
		int card;
		SWAPS=999999;

		for(int card1=0; count <=SWAPS; count++)
		card2 = randomCard.nextInt(TOTAL);

		Card temp = deck[card];
		deck[card]=deck[card2];
		deck[card2]=temp;
	}

//----------------------------
//Deals a card from the deck
//----------------------------
public Card dealCard()
{
	if(currentCard < deck.length)
	return deck[currentCard ++];
}

			//---------------------------
			//Cards left in the deck
			//---------------------------
							public int cardsLeft()
							{

						return 52 - cardsDealt;
					}
}


 


import javax.swing.*;
import java.util.Random;

public class DeckOfCardsDriver
{
	//----------------------------------------------------
		//Main method that creates a new DeckofCards, shuffles
		//the deck, and then deals two five-card playing hands
		//for a game of poker.
	//----------------------------------------------------
	public static void main (String[]args)
	{
		DeckOfCards cardDeck = new DeckOfCards();
		cardDeck.shuffle();

			  //------------------------------
			  // deals and print two five-cards
		 	 //-------------------------------

		for (int index=0;index < 13; index ++)
		{
			System.out.println("%-10s%-10s\n", cardDeck(), cardDeck());
		}
	}
}

Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,913
  • Joined: 06-March 08

Re: Card game

Posted 26 April 2009 - 06:26 PM

View Postswim_fan08, on 26 Apr, 2009 - 04:13 PM, said:

I went back and edited my code again, but my compiler is still complaining about line 29 and 30 in my DeckOfCards file where I have ACE, TWO, THREE etc and the SPADES, HEARTS , and DIAMONDS etc.

Compiler is right to complain... where are they defined ?
Was This Post Helpful? 0
  • +
  • -

#7 swim_fan08  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 302
  • Joined: 19-February 09

Re: Card game

Posted 26 April 2009 - 07:53 PM

View Postpbl, on 26 Apr, 2009 - 05:26 PM, said:

View Postswim_fan08, on 26 Apr, 2009 - 04:13 PM, said:

I went back and edited my code again, but my compiler is still complaining about line 29 and 30 in my DeckOfCards file where I have ACE, TWO, THREE etc and the SPADES, HEARTS , and DIAMONDS etc.

Compiler is right to complain... where are they defined ?


I have them defined in my Card class.

public class Card
{
   public final static int ACE   = 1;
   public final static int TWO   = 2;
   public final static int THREE = 3;
   public final static int FOUR  = 4;
   public final static int FIVE  = 5;
   public final static int SIX   = 6;
   public final static int SEVEN = 7;
   public final static int EIGHT = 8;
   public final static int NINE  = 9;
   public final static int TEN   = 10;
   public final static int JACK  = 11;
   public final static int QUEEN = 12;
   public final static int KING  = 13;

   public final static int CLUBS	= 1;
   public final static int DIAMONDS = 2;
   public final static int HEARTS   = 3;
   public final static int SPADES   = 4;

   private final static int NUM_FACES = 13;
   private final static int NUM_SUITS = 4;

   private int face, suit;
   private String faceName, suitName;

   //-----------------------------------------------------------------
   //  Creates a random card.
   //-----------------------------------------------------------------
   public Card ()
   {
	  face = (int) (Math.random() * NUM_FACES) + 1;
	  setFaceName();

	  suit = (int) (Math.random() * NUM_SUITS) + 1;
	  setSuitName();
   }

   //-----------------------------------------------------------------
   //  Creates a card of the specified suit and face value.
   //-----------------------------------------------------------------
   public Card (int faceValue, int suitValue)
   {
	  face = faceValue;
	  setFaceName();

	  suit = suitValue;
	  setSuitName();
   }

   //-----------------------------------------------------------------
   //  Sets the string representation of the face using its stored
   //  numeric value.
   //-----------------------------------------------------------------
   private void setFaceName()
   {
	  switch (face)
	  {
		 case ACE:
			faceName = "Ace";
			break;
		 case TWO:
			faceName = "Two";
			break;
		 case THREE:
			faceName = "Three";
			break;
		 case FOUR:
			faceName = "Four";
			break;
		 case FIVE:
			faceName = "Five";
			break;
		 case SIX:
			faceName = "Six";
			break;
		 case SEVEN:
			faceName = "Seven";
			break;
		 case EIGHT:
			faceName = "Eight";
			break;
		 case NINE:
			faceName = "Nine";
			break;
		 case TEN:
			faceName = "Ten";
			break;
		 case JACK:
			faceName = "Jack";
			break;
		 case QUEEN:
			faceName = "Queen";
			break;
		 case KING:
			faceName = "King";
			break;
	  }
   }

   //-----------------------------------------------------------------
   //  Sets the string representation of the suit using its stored
   //  numeric value.
   //-----------------------------------------------------------------
   private void setSuitName()
   {
	  switch (suit)
	  {
		 case CLUBS:
			suitName = "Clubs";
			break;
		 case DIAMONDS:
			suitName = "Diamonds";
			break;
		 case HEARTS:
			suitName = "Hearts";
			break;
		 case SPADES:
			suitName = "Spades";
			break;
	  }
   }

   //-----------------------------------------------------------------
   //  Determines if this card is higher than the passed card. The
   //  second parameter determines if aces should be considered high
   //  (beats a King) or low (lowest of all faces).  Uses the suit
   //  if both cards have the same face.
   //-----------------------------------------------------------------
   public boolean isHigherThan (Card card2, boolean aceHigh)
   {
	  boolean result = false;

	  if (face == card2.getFace())
	  {
		 if (suit > card2.getSuit())
			result = true;
	  }
	  else
	  {
		 if (aceHigh && face == ACE)
			result = true;
		 else
			if (face > card2.getFace())
			   result = true;
	  }

	  return result;
   }

   //-----------------------------------------------------------------
   //  Determines if this card is higher than the passed card,
   //  assuming that aces should be considered high.
   //-----------------------------------------------------------------
   public boolean isHigherThan (Card card2)
   {
	  return isHigherThan (card2, true);
   }

   //-----------------------------------------------------------------
   //  Returns the face (numeric value) of this card.
   //-----------------------------------------------------------------
   public int getFace ()
   {
	  return face;
   }

   //-----------------------------------------------------------------
   //  Returns the suit (numeric value) of this card.
   //-----------------------------------------------------------------
   public int getSuit ()
   {
	  return suit;
   }

   //-----------------------------------------------------------------
   //  Returns the face (string value) of this card.
   //-----------------------------------------------------------------
   public String getFaceName ()
   {
	  return faceName;
   }

   //-----------------------------------------------------------------
   //  Returns the suit (string value) of this card.
   //-----------------------------------------------------------------
   public String getSuitName ()
   {
	  return suitName;
   }

   //-----------------------------------------------------------------
   //  Returns the string representation of this card, including
   //  both face and suit.
   //-----------------------------------------------------------------
   public String toString ()
   {
	  return faceName + " of " + suitName;
   }
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1