-1

In my method, I am trying to use a declared constant called CLB in my main method. This constant is in another class called Card. When I try to to use setSuit, a method I wrote, in the main class, it gives me "Symbol not found"

I have a class called Card...

public class Card {

private char value;
private char suit;
public String card = "";
final int NOC = 52; //number of cards
final int NOF = 4;  //number of faces
final int NOV = 13; //number of values

//SUITS; 3 letter designation
private final char CLB = '\u2663';
private final char SPD = '\u2660';
private final char HRT = '\u2764';
private final char DMN = '\u2666';

//Array of suits and values
public char[] cardSuit = {CLB, SPD, DMN, HRT};
public char[] cardValue = {'A', 'K', 'Q', 'J', 10, 9, 8, 7, 6, 5, 4, 3, 2};    


//CONSTRUCTOR
public Card(){}

public Card(char suit, char value)
{
    this.suit = suit;
    this.value = value;        
}

public void setSuit(char s)
{
    if (contains(cardSuit, s)) 
    {
        suit = s;
    }

Here is main...

public static void main(String[] args) {
    Card test = new Card();
    test.setSuit(CLB);

I'm not quite sure what I'm doing wrong since in my understanding, the object test should contain the suits.

cybernautmik
  • 63
  • 1
  • 8

2 Answers2

2

Declare it as following:

public final static char CLB = '\u2663';

and call it like

Card.CLB 
MS90
  • 1,219
  • 1
  • 8
  • 17
0

If you're main method is in another class, you need to make CLB public(public final char CLB = '\u2663';) and also reference CLB like this: Card.CLB

Justin
  • 1,356
  • 2
  • 9
  • 16