4.2 Set Up the Choice

Right now, we’re asking the player to choose playing with odds or evens. This choice determines the computer’s side and the round winner.

To be able to use the player choice in the game, we need to store it in a variable.

🎓 Learn


For now, let’s assume the player choice is always 1 (odds) and declare the variable to store it:

  1. Data Type: int (Integer).
  2. Name: playerSide.
  3. Initial Value: 1.

What to Do

🙈 Solution
Tried, you must, before reveal the solution you may. - Yoda

✏️ 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);
++  int playerSide = 1;

🗒️ Program.cs - Final

GamePrint.Box("Welcome to the Odds and Evens Game!");

// Player chooses to play with odds or evens.
GamePrint.Input("Choose 1 for Odds or 2 for Evens");
GameInput.Number(1, 2);
int playerSide = 1;

(...)