public class Connect4Model
{
    Connect4Column [] columns; // Cannot find symbol
    private int NUM_COLUMNS;
    private int NUM_ROWS;
    private int playerToGoNext = Connect4Column.RED_COUNTER; // cannot find symbol

    Connect4Model(int numCols, int numRows); // Missing method body...Is this because I'm missing a curly braces just above 
    {
        columns = new Connect4Column[NUM_COLUMNS];

        for (int i = 0;i < NUM_COLUMNS;i++)
        {
            columns[i] = new Connect4Column(NUM_ROWS); //Cannot find Connect4Column symbol 
        }
    }
    int getNumCols()
    {
        return 0;
    }
    int getNumRows()
    {
        return 0;
    }
    int getNextPlayer()
    {
        return 0;
    }
    boolean go(int thisColumn)
    {
        return true;
    }
    int getCounter(int thisColumn, int thisRow)
    {
        return 0;
    }
    int getNumCounters(int thisColumn)
    {
        if(thisColumn >= 0 && thisColumn < NUM_COLUMNS)
        {
            return my_array[thisColumn]; /// Cannot find my symbol my_array[thisColumn]
        }
        else
        {
            return 0;
        }
    }

}

What I'm trying to do is that in the constructor, I will assign NUM_COLUMNS and NUM_ROWS to take the values of the input parameters, and then make the column objects. But I know that in order to make the objects, i need to make the array of these objects. But I don't know why these errors are appearing.

Recommended Answers

All 10 Replies

i think Connect4Column is a class..

how can you instantiate such class as an array...

i can't understand what u done...

Have you defined a Connect4Column class?

Also I have given suggestions in the other thread which you didn't follow. (About the ';').

The constructor seems ok though. If it is the same as before then I must have missed something.

Next time use Code tags. Press the button: (code) when you make a new post

i think Connect4Column is a class..

how can you instantiate such class as an array...

i can't understand what u done...

It can be done. Provided of course that such a class exists.

Yes I have defined a new class called Connect4Column.

I have defined another class called Connect4Column. I have sorted the cannot find symbols. Its just the one error
cannot find symbol symbol : variable my_array location: class Connect4Model
return my_array[thisColumn];

I have defined another class called Connect4Column. I have sorted the cannot find symbols. Its just the one error
cannot find symbol symbol : variable my_array location: class Connect4Model
return my_array[thisColumn];

Have you declared such a variable?

Have you declared such a variable?

No I haven't.

yes, of course i know it..

but it will be assigned to array variable..

that was missed..

{
    Connect4Column [] columns; // Cannot find symbol
    **see here you have not declared the type of variable is column**
    private int playerToGoNext = Connect4Column.RED_COUNTER; // cannot find symbol

    Connect4Model(int numCols, int numRows); // Missing method 

here you have given a ";" which will not write

{
    columns = new Connect4Column[NUM_COLUMNS];

    for (int i = 0;i < NUM_COLUMNS;i++)
    {
        columns[i] = new Connect4Column(NUM_ROWS); //Cannot find Connect4Column symbol 
    }
}
int getNumCols()
{
    return 0;
}
int getNumRows()
{
    return 0;
}
int getNextPlayer()
{
    return 0;
}
boolean go(int thisColumn)
{
    return true;
}
int getCounter(int thisColumn, int thisRow)
{
    return 0;
}
int getNumCounters(int thisColumn)
{
    if(thisColumn >= 0 && thisColumn < NUM_COLUMNS)
    {
        return my_array[thisColumn]; /// Cannot find my symbol my_array[thisColumn]
    }
    else
    {
        return 0;
    }
}

}

basically cannont find symbol appears when you have not declared a data type for the variable.... in many places you havnt declared one try declaring all the variable one by one and then compile....
chao...

start quote:

{
    Connect4Column [] columns; // Cannot find symbol
    **see here you have not declared the type of variable is column**
    private int playerToGoNext = Connect4Column.RED_COUNTER; // cannot find symbol

    Connect4Model(int numCols, int numRows); // Missing method 

**here you have given a ";" which will not write**

{
        columns = new Connect4Column[NUM_COLUMNS];

        for (int i = 0;i < NUM_COLUMNS;i++)
        {
            columns[i] = new Connect4Column(NUM_ROWS); //Cannot find Connect4Column symbol 
        }
    }
    int getNumCols()
    {
        return 0;
    }
    int getNumRows()
    {
        return 0;
    }
    int getNextPlayer()
    {
        return 0;
    }
    boolean go(int thisColumn)
    {
        return true;
    }
    int getCounter(int thisColumn, int thisRow)
    {
        return 0;
    }
    int getNumCounters(int thisColumn)
    {
        if(thisColumn >= 0 && thisColumn < NUM_COLUMNS)
        {
            return my_array[thisColumn]; /// Cannot find my symbol my_array[thisColumn]
        }
        else
        {
            return 0;
        }
    }

}

basically cannont find symbol appears when you have not declared a data type for the variable.... in many places you havnt declared one try declaring all the variable one by one and then compile....
chao...

I should have known better. Thanks

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.