Take out that line 6. A loop is not proper there, line 5 has already removed the tile and false==false, always.
You need to test the state of tile before you update it. So line 4 is the place. Test.
if
You have two things that you can do.
Either you can remove a tile,
or you have to quit the while(true) loop.
You can remove a tile if it is present.
1 2 3 4 5 6 7 8
|
if ( /*tile is present*/ )
{
// update tile
}
else
{
break;
}
|
What would be correct
/*tile is present*/
?
It is a
condition.
Wait, we were using
ternary operator in output loop. What was its syntax?
condition ? result1 : result2 |
Can we use the same condition here? Yes.
And then not quite. You have the other branch that removes two tiles. They have to
both be present. That needs a more complex condition; you need
boolean and. If tile1 is present and tile2 is present.
As a side project write a loop at the end of the program that calculates score and then show the score.