Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+16 votes

I know in do/while loops it will be executed at least once so is this the type of loop I would want to use or is there cases where you may not need it to be executed?

asked in CSC211_Winter2018 by (1 point)

1 Answer

+6 votes

Use a while loop for the Catch It program for the main game loop. If the user closed the game panel while the opening screens were executing, then the game loop would never be executed.

As far as a loop to wait for a mouse click, I would use a while..loop. Personally, I like the conditional expression at the top of the loop unless there is a compelling reason to use a do..while loop.

answered by (1 point)
...