The Number Guessing Game GROUP MEMBERS: Rohan Arshad Muhammad Danyal Hashir Khan Wajahat Awan Ra
Contents Overview Introduction to fundamental programming concepts. Design and Function Implementation Explanation of program design. Steps to implement functions. Flow Chart Visual representation of program logic. Key components of the flow chart. Explanation of Flow Chart Detailed breakdown of each step. How the flow chart guides program execution. Conclusion Summary of key points. Final thoughts on the importance of fundamental programming. Questions Open floor for audience questions. Clarifications and further discussions. Fun Activity Time Interactive coding challenge or game .
1. Overview The Number Guessing Game is a simple console-based game designed to test the player's guessing ability. The game offers three difficulty levels—easy, medium, and hard—each providing a different number of attempts to guess a random number between 1 and 100. Additionally, the game includes a special mission where players can play Rock-Paper-Scissors to earn hints or lose attempts. The game saves scores and game counts to files, allowing players to track their performance over multiple sessions .
Difficulty Levels Easy Players have 7 attempts to guess the random number, with the opportunity to earn a hint by winning a Rock-Paper-Scissors game against the computer. Medium The challenge increases with only 5 attempts to correctly guess the number, but the chance to gain a valuable hint remains. Hard The ultimate test of skill, players must guess the number within just 3 attempts, making the Rock-Paper-Scissors mission a crucial strategy to secure a hint.
Random Number Generation 1 Seeding the Random Number The game utilizes the current time to seed the random number generator, ensuring a unique and unpredictable number is chosen each time the game is played. 2 Generating the Number The random number is generated within the range of 1 to 100, providing a fair and challenging target for the player to guess. 3 Storing the Number The generated random number is securely stored and used as the target for the player to guess, adding an element of mystery and suspense to the game.
The Special Mission 1 Rock-Paper-Scissors Before the main game begins, players are given the opportunity to play a special Rock-Paper-Scissors game against the computer. 2 Earning Hints If the player wins the Rock-Paper-Scissors game, they are rewarded with a valuable hint to assist them in guessing the random number. 3 Risking Attempts Losing the Rock-Paper-Scissors game, however, results in the player losing two of their precious attempts to guess the number correctly.
Scoring and Saving Scoring The game awards points based on the number of attempts remaining when the player correctly guesses the number, encouraging strategic play and rewarding skill. Saving Progress Player scores and the total number of games played are saved to files, allowing for the tracking of personal bests and overall progress. Loading Scores The game can load previous scores and game counts from the saved files, enabling players to pick up where they left off and compare their achievements.
2.Design and Function Implementation . The game is designed using C++ and incorporates several key components: Welcome Message and Difficulty Levels : WelcomeMESSAGE (): Displays the initial welcome message and instructions . DifficultyLvlMESSAGE (): Displays the difficulty level selection message Random Number Generation: genRandomNUMBER ():. Generates a random number between 1 and 100 using the rand() function seeded with the current time
Special Mission - Rock-Paper-Scissors: SpecialRockPaperScissors (): Implements the Rock-Paper-Scissors game where players can earn hints or lose attempts based on the outcome . Score and Game Count Management: saveSCORES ( int scores[], int size): Saves the scores to a file. loadSCORES (): Loads and displays previous scores from a file . saveGAMEcount ( int count): Saves the total number of games played to a file . loadGAMEcount (): Loads the total number of games played from a file Gameplay: playGAME ( int attempts, bool &hint): Manages the main gameplay loop, taking the number of attempts and a hint flag as parameters User CHOICE( int level): Handles user input for selecting difficulty levels and starts the game accordingly.
3.Flow Chart
Interface
Exceptions Handling
4.Conclusion: The Number Guessing Game project demonstrates the application of basic C++ programming concepts, including input/output operations, random number generation, and file handling. The game is interactive and engaging, with multiple difficulty levels and an additional Rock-Paper-Scissors mini-game for added complexity. Future enhancements could include more detailed statistics, additional game modes, and a graphical user interface for a more immersive experience