Break down Mechanics

📖 Instructions#

An essential step in learning programming is learning how to think like a programmer.

This means breaking down goals or problems into clear steps. It helps you understand the problem and prevents you from missing important parts.

In this case, the goal is to build an Odds and Evens game where the player plays against the computer. Start by understanding how the game works: how it begins, how each round is played, and how the winner is decided.

Then, translate that understanding into steps. Write down everything that needs to happen, from starting the game to displaying the result.

✅ What to Do#

  • Read the rules (external link) and make sure you know how the game works.
  • Write down all the steps required, from starting the game to showing the result.

💡 Hints#

Hint 1

Define the goal of the game. What should happen from start to finish?

Hint 2

Identify the inputs and outputs. What does the player enter, and what should be shown?

Hint 3

Clarify the rules. How do you determine the result or winner?

Hint 4

Break the solution into ordered steps. What happens first, next, and last?

🙈 Solution#

Tried, you must, before reveal the solution you may.
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.