0
while((board.getgXPos() != board.getXPos()) && (board.getgYPos() != board.getYPos()))
{
system("cls");
board.printBoard();
board.moveBall();
}

I would like this while statement to continue repeating until both gxPos equals XPos & gyPos equals YPos.

I can't seem to figure out why the statement exits if either both x's are the same or if both y's are the same.

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Murtan
1

So you want the loop to keep running while the xPos is different or the yPos is different. You wrote while the xPos is different AND the yPos is different. The loop needs to run while either doesn't match.

while((board.getgXPos() != board.getXPos()) || (board.getgYPos() != board.getYPos()))
Votes + Comments
Helpful!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.