I am trying to make the buttons work for my scenario. I am trying to get them to function (and I have called it) but, they still don't work. I was trying to implement Super_Hippo's code into these buttons (addNumbers for check and removeRows for clear. I still can't figure out how to do it or where to call the function. I want the 'g' key for check and the 'j' key for clear. Please help!
World Code I want In the Button Check
World Code I want in the Button Clear
If you need anymore code, please ask and I will provide. They will be inside if statements checking if one of those keys were pressed. Thanks in advance!
private void addNumber(int i)
{
//Spawns in a number from the ArrayList to the world in the correct place
addObject(numbers.get(i), i%9*(cellSize) + cellSize/2, topSpace + i/9*(cellSize) + cellSize/2);
}
private void addNumbers()
{
int size = numbers.size();
//Adds all unsolved numbers to the ArrayList
for(int i = 0; i < size; i++)
{
if(!numbers.get(i).getSolved())
{
numbers.add(new Number(numbers.get(i).getValue()));
}
}
//Spawns in all the numbers from the ArrayList
for(int i = size; i < numbers.size(); i++)
{
addNumber(i);
}
}private void removeRow(int row)
{
//Removes all of the numbers in a row
for(int i = 0; i < 9; i++)
{
removeObject(numbers.get(row*9+(8-i)));
numbers.remove(row*9+(8-i));
}
//Moves up the rows beneath the removed row
for(int i = row*9; i < numbers.size(); i++)
{
numbers.get(i).changeHeight(- cellSize);
}
}
private void removeRows(int row1, int row2)
{
//If two entire rows have a value of -1, remove the second one first
if(row1 == -1)
{
if(row2 == -1)
{
return;
}
removeRow(row2);
}
//If one entire row has a value of -1, remove it
else
{
if(row2 == -1)
{
removeRow(row1);
return;
}
removeRow(row1>row2 ? row1 : row2);
removeRow(row1>row2 ? row2 : row1);
}
}

