Using enums in Java across multiple classes

Posted by Richard Mar. on Stack Overflow See other posts from Stack Overflow or by Richard Mar.
Published on 2011-01-08T16:45:47Z Indexed on 2011/01/08 16:53 UTC
Read the original article Hit count: 170

Filed under:
|
|

I have the following class:

public class Card 
{
    public enum Suit 
    {
        SPACES, HEARTS, DIAMONDS, CLUBS
    };

    public Card(Suit nsuit, int nrank)
    {
        suit = nsuit;
        rank = nrank;
    }

    private Suit suit;
    private int rank;
}

I want to instantiate it in another class, but that class doesn't understand the Suit enum. Where should I put the enum to make it publicly visible?

© Stack Overflow or respective owner

Related posts about java

Related posts about class