Modular breakdown
Learn how to break down the game into its components.
We'll cover the following
How to start
Before we delve into the coding aspects of this project, let’s spend some time understanding its workflow. A strong understanding of the project and its requirements will go a long way in helping us as we build our project. Based on what we observed while playing the game in the previous lesson, let’s go through the logical breakdown of the program step by step.
Display instructions: Present the rules and instructions of the game to the user so they understand how to play.
Input number of rounds: Prompt the user to enter how many rounds they want to play.
Input user’s choice: Ask the user to choose between rock, paper, or scissors for the current round.
Determine the computer’s choice: To determine the computer’s choice, randomly select rock, paper, or scissors.
Check round winner and update score: Compare the user’s choice and the computer’s choice to determine the round’s winner and update the scores accordingly.
Check if all rounds are done: Verify if the specified number of rounds has been played. If not, loop back to input the user’s choice for the next round.
Determine winner: After all rounds are completed, compare the final scores to determine the overall winner of the game.
Display results: Show the final results, including the scores and the overall winner, to the user.
Get hands-on with 1400+ tech skills courses.