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;
   }
}

Recommended Answers

All 3 Replies

Member Avatar for Dukane

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;
	}

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

Member Avatar for Dukane

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!

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.