Answered step by step
Verified Expert Solution
Question
1 Approved Answer
EDIT: The game automatically moves onto the next stage CS 202 - Assignment #2 Purpose: Due: Points: Learn simple class implementation. Sunday (209) 100 Rock
EDIT: The game automatically moves onto the next stage
CS 202 - Assignment #2 Purpose: Due: Points: Learn simple class implementation. Sunday (209) 100 Rock Assignment: The game Rock-Paper-Scissors. is a two-person hand game. The game is often used as a selection method similar to coin flipping or drawing straws to randomly select a winner. However, unlike truly random selections, if the game extends over many sessions, a Lizard Paper Je player can often recognize and exploit the non-random behavior of an opponent. Spock Scissors A popular extension is the Rock-Paper-Scissors-Lizard- Spock' game and was featured on the television show Big Bang Theory. This extension adds a significant Scissors cuts Paper covers Rock crushes number of additional possible outcomes and is thus Lizard poisons Spock smashes Scissors more random decapitates Lizard eats Paper disproves Spock vaporizes Rock crushes Scissors, Design and implement a C++ class for the Rock-Paper- Scissors-Lizard-Spock (RPSLS) game. The class will incorporate all functions and data required for the game, including multi-game tracking (e.g., games played, wins, losses, ties). The rpsls Type UML class diagram is as follows: rpslsType -userWins: int -userLosses: int -games Played: int + pels Type() +play Round(): void +showScores(): void +reset Scores(): void +playAgain(): bool +get Scores (int &, int &, int k): void -showRound(): void -getUserMove (): int -getComputerMove (): int The header file is provided. You will need to develop an implementation file based on the above UML diagram (which is represented in the provided header file). Your implementation and header files should be fully commented. Function Descriptions: The following are more detailed descriptions of the required functions. The rpsls Type() constructor should initialize the class variables (all O's for this object). The showScores() function should display the score statistics to the screen. The format should closely match the provided examples. The resetScores() mutator function should reset the class variables for score tracking (to O's). The getScores(int &, int &, int &) const accessor function should return the games played, user wins, and user losses in that order) via reference. The boolean playAgain() function should prompt the user if they want to play again. The function should read 'Y'/y/N' and return true for 'Y/y' and false for N'. If invalid input is entered, the function should provide an error message and re-prompt. Refer to the example executions for the formatting and error messages. The playRound() function should play a single round of Rock-Paper-Scissors-Lizard-Spock. This will involve getting the user move (via getUser Move( function) and then the get computer move (via the getComputer Move() function). Based on that information, the function should select a winner, display the results, and update the applicable class variables for games played, user wins, or user loss. Choose winner based on the following rules: Scissors cut paper, Paper covers rock. Rock crushes lizard. Lizard poisons Spock. Spock smashes scissors, Scissors decapitate lizard. Lizard eats paper. Paper disproves Spock. Spock vaporizes rock. Rock crushes scissors. Note, the function will be reviewed for efficiency. An overly complex approach will be marked down significantly The private integer getComputer Move() function should use the C++ rand function to select the computer move by returning an integer between 1 and 5 (inclusive) The private integer getUser Moved function should prompt the user for a move selection ('1' - '5, '1-Rock, '2'=Paper, 3'-Scissors, 4'-Lizard, and '5'=Spock). The function must ensure that the user selection is between '1'-'5. If correct input is received, the function should return the integer (between 1 and 5, inclusive). If incorrect input is entered, the function should should display an error message and re-prompt. The function must be able to handle invalid input, including invalid character input (i.e., if user enters a 'R', which is incorrect/invalid). Refer to the example executions for output formatting. Make sure your program includes the appropriate documentation. See Program Evaluation Criteria for CS 202. Submission: When complete, submit: A copy of the source files (i.e., main.cpp, rpslsType.h, and rpsisImp.cpp) via the class web page (assignment submission link) by class time on the due date. Example Executions: Below is an example program execution showing the I/O formatting. ed-ubuntu: ../ast02 . . . . . . . . . . . . . . . . . . . . . . . CS 202 - Assignment #2 Rock Paper Scissors Lizard Spock Game Stage 1 - Best of 5 games Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock Rock crushes lizard. You win! Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock 2 Tie! Please try again! Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock Tie! Please try again! Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : 0 Error, invalid input. ------------------- Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock 1 Rock crushes lizard. Sorry, you lose. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : five Error, invalid input. ----------- Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock 5 Scissors decapitate lizard. You win! Score Summary Games Played: 5 User wins: 2 User losses: 1 Game Ties: 2 Stage 2 - Unlimited Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock Tie! Please try again! Play again (Y/y/N): 9 Error, invalid response. Plese re-enter. Play again (Y/y/N): 4 Error, invalid response. Plese re-enter. Play again (Y/y/N): Y Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : 2 Tie! Please try again! Play again (Y/y/N): Y Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : 1 Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock : Error, invalid input. Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock 3 Tie! Please try again! Play again (Y/y/N): n Score Summary Games Played: 3 User wins: 0 User losses: 0 Game Ties: 3 EFE Stage 1 - One game, All-or-Nothing Enter Move 1 - Rock 2 - Paper 3 - Scissors 4 - Lizard 5 - Spock Spock smashes scissors. Sorry, you lose. Spock smashes scissors. Sorry, you lose. Score Summary Games Played: 1 User wins: 0 User losses: 1 Game Ties: 0 Program Terminated ed-ubuntu: // Rock-Paper-Scissors-Lizard-Spock game class header file. // Includes. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started