3.3 Write the Game Logic

Here are the steps to implement an Odds and Evens Game:

  1. Player chooses to play with odds or evens.
  2. Player enters a number between 1 and 2.
  3. Computer randomly generates a number between 1 and 2.
  4. Add the two numbers.
  5. Check if the sum is odd or even.
  6. Decide the round winner.
  7. Repeat rounds until one of the players wins two times.
  8. Announce the game winner.
  9. Ask the player to play again or quit.

Weโ€™ll use these steps as a roadmap, guiding us through the game implementation.

You can write them in the program using comments.

๐ŸŽ“ Learn


โœ… What to Do


๐Ÿ™ˆ Solution
Tried, you must, before reveal the solution you may. - Yoda

โœ๏ธ Program.cs - Changes

    GamePrint.Box("Welcome to the Odds and Evens Game!");
++
++  // Player chooses to play with odds or evens.
++  // Player enters a number between 1 and 2.
++  // Computer randomly generates a number between 1 and 2.
++  // Add the two numbers.
++  // Check if the sum is odd or even.
++  // Decide the round winner.
++  // Repeat rounds until one of the players wins two times.
++  // Announce the game winner.
++  // Ask the player to play again or quit.

๐Ÿ—’๏ธ Program.cs - Final

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

// Player chooses to play with odds or evens.
// Player enters a number between 1 and 2.
// Computer randomly generates a number between 1 and 2.
// Add the two numbers.
// Check if the sum is odd or even.
// Decide the round winner.
// Repeat rounds until one of the players wins two times.
// Announce the game winner.
// Ask the player to play again or quit.