Level 6: SCRIPTING CONTROL FLOW
11/6/19 - While Loop and Do While Loop
- After the above tutorial, create a new C# script (called DoWhileLoop) in your Scripts folder
- Watch "Loop Do While" (video shown below)
Assignment:
- After you finish watching the above tutorial, resave your L6Practice scene.
- Reopen your L6Assignment scene
- Create a new C# script (called BestGameEver) in your Scripts folder.
- For this script, a variable will be created called bestGameEver (publically) which asks the user to input their favorite game of all time (see Illustration 1 to see how this will look in the Inspector window). Another variable will be created called repeat which will be equal to 5. Using a WHILE loop, the following will print in the Console window: "____________ (BestGameEver variable) is the best game ever made! I'll say it _______ (repeat variable) more times!". The WHILE loop will then create another statement and decrease the repeat variable by 1. And this will continue until the statement says "...2 more times". At that time, two final statements will be printed in the Console window (one for "1 more time" and another as a "Goodbye" statement). See Illustration 2 to see how this will look in the Console window.