With a clear guide, we can now tackle the first step.
In the first step:
💻 C#
// Player chooses to play with odds or evens.To complete this step we need:
Programming
languages don’t understand what is odds or evens. A common approach
is to assign numbers instead: 1 for odds and 2
for evens.
Asking for input is usually a bit more advanced, so we’ll use a helper function from the Game Utilities. It defines two parameters to accept a valid range of numbers:
💻 C#
// Accepts a number between 1 and 2.
GameInput.Number(1, 2);The function only receives input. It doesn’t explain to the player what to write. This means we need to print a message before asking for input.
The GameUtilities include a function to print messages
formatted for input requests:
💻 C#
GamePrint.Input("Choose a number between 1 and 2");
GameInput.Number(1, 2);🖨️ Console
--> Choose a number between 1 and 2:
1
⚠️ The input function pauses the program control flow until the player enters valid input.
✅ What to Do
🎯 Expected Outcome
🖨️ Console
+--------------------------------+
+-- Welcome to Odds and Evens! --+
+--------------------------------+
--> Choose 1 for Odds or 2 for Evens:
1
✏️ Program.cs - Changes
// Player chooses to play with odds or evens.
++ GamePrint.Input("Choose 1 for Odds or 2 for Evens");
++ GameInput.Number(1, 2);🗒️ Program.cs - Final
GamePrint.Box("Welcome to Odds and Evens!");
// Player chooses to play with odds or evens.
GamePrint.Input("Choose 1 for Odds or 2 for Evens");
GameInput.Number(1, 2);
(...)