I'm running to compiler error while I'm trying to use Enum to create a program that display a deck of cards. The compiler mistake is "Cannot find symbol", but I did call the constructor and use method call to call the method in card class. It still give me compiler error. I don't know why.
Here is the code for card class:
public class Card
{
public enum Suit{ DIAMONDS, CLUBS,HEARTS,SPADES}
public enum Rank
{
ACE,DEUCE,THREE,FOUR,FIVE,SIX,
SEVEN,EIGHT,NINE,TEN,JACK,QUEEN,
KING
}
private final Rank rank;
private final Suit suit;
public Card(Rank rank,Suit suit)
{
this.rank = rank;
this.suit = suit;
}
public Suit getSuit()
{
return suit;
}
public Rank getRank()
{
return rank;
}
@Override
public String toString()
{
return rank + " of " + suit;
}
}
It compile for the card class.
import java.util.*;
public class Deck
{
private static Card[] cards = new Card[52];
public Deck()
{
Card car = new Card();
for (Suit suit : car.Suit.values())
for (Rank rank: car.Rank.values())
cards.add( new cards(rank, suit));
}
public Card[] getCards()
{
return cards;
}
The compiler error occur in this class. The message is "Cannot find symbol." I have not create a display class yet, but I will. I just need to get my deck class. Where did I do wrong in my code? Thank you so much.