954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

'(' error and not a statement error

currently writing a program, and for some reason I'm getting these two errors which are really bugging me. I've tried adding the brackets and changing the statement and still no luck. If there is a possible solution that would be grateful. Please note that I have solved the bracket error, I now have the 'not a statement error'

public class AbacusCalcModel
{
	private int num_of_columns;
	private int max_num_counters;
	private int my_array[];
	private int curColumn;

	public AbacusCalcModel(int num_columns, int num_counters)
	{
		max_num_counters = num_counters;
		num_of_columns = num_columns;
		my_array = new int[num_of_columns];
		curColumn = num_of_columns;
	}

	boolean addCounter(int thisCol)
	{
		if ((thisCol >= 0)&&(thisCol < num_of_columns)&&(my_array[thisCol] <= max_num_counters))
				{
					if ((my_array[thisCol] == 9)&&(thisCol == curColumn))
					{
						carryAdd(thisCol);
						return true;
					}
					else if ((my_array[thisCol] == 9)&&(thisCol == curColumn))
					{
						return false;
					}
					else
					{
						my_array[thisCol]++;
						return true;
					}
				}
				else
				{
					return false;
		}
	}

	boolean removeCounter(int thisCol)
	{
		if ((my_array[thisCol] > 0)&&(thisCol >= 0)&&(thisCol <= num_of_columns))
		{
			my_array[thisCol]--;
			return true;
		}
		else
		{
			return false;
		}
	}

	int getNumCounters(int thisCol)
	{
		if ((thisCol >= 0)&&(thisCol < num_of_columns))
		{
			return my_array[thisCol];
		}
		else
		{
			return 0;
		}
	}

	private boolean carryAdd(int thisCol)
	{
		int i = thisCol;
		if ((my_array[i] == 9)&&(i < curColumn))
		{
			i++;
		}

		else
		{
			return false;
		}

		if (my_array[i] < 9)
		{
			my_array[i]++;
		}

		if ( i < curColumn)
		{
			for int x = thisCol; x < i; x++)
			{
				if (my_array[x] == 9)
				{
					my_array[x] == 0;
				}
			}
		}
	   return true;
   }
}
ku95
Light Poster
25 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Line 90, you are using the comparison operator (==) where you should be using the assignment operator (=).

if (my_array[x] == 9)
	{
		my_array[x] == 0;
	}


should be

if (my_array[x] == 9)
	{
		my_array[x] = 0;
	}
Dukane
Posting Whiz in Training
295 posts since Oct 2006
Reputation Points: 45
Solved Threads: 29
 

I just managed to sort it just as you have posted this. Thanks for the reply though much appreciated

ku95
Light Poster
25 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 
I just managed to sort it just as you have posted this. Thanks for the reply though much appreciated


You should mark the thread as solved now!

Dukane
Posting Whiz in Training
295 posts since Oct 2006
Reputation Points: 45
Solved Threads: 29
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You