Question: Using all of these functions below, write a C program meeting the requirements: int convertShape(char* shape); void displayResults(char* sheldonsInitialShape, int sheldonWins, char* leonardsInitialShape, int leonardWins,
Using all of these functions below, write a C program meeting the requirements: int convertShape(char* shape); void displayResults(char* sheldonsInitialShape, int sheldonWins, char* leonardsInitialShape, int leonardWins, int ties); int determineLeonardsNextShape(int sheldonsCurrentShape, int leonardsCurrentShape, int gameOutcome); int determineSheldonsNextShape(int sheldonsCurrentShape, int leonardsCurrentShape, int gameOutcome); int determineWinner(int sheldonsShape, int leonardsShape); int getBetterShape(int shape); void playGame(int sheldonsInitialShape, int leonardsInitialShape, int numberGames, int *pSheldonsWinCount, int *pLeonardsWinCount, int *pTieCount); void updateScores(int gameOutcome, int *pSheldonsWinCount, int *pLeonardsWinCount, int *pTieCount);
Important Notes
DO NOT modify the provided function declarations
DO NOT create any additional functions
Include the string header (#include )
Format the output using the sample output in the Example Output section as a guide
Review the Command-Line Arguments page for instructions on using command-line arguments in Visual Studio
Throughout the project, the term shape refers to any one of the legal moves: rock, paper, scissors, lizard, or Spock
Project Requirements
The program MUST accept command-line arguments (see the appropriate note above)
Display your name and the project title on separate lines, followed by a blank line
Test whether the correct number of command-line arguments were provided
The program requires 3 values, but 4 values are present in the command-line arguments
If the correct number of command-line arguments are not provided
Display an appropriate error message
Exit to the operating system WITHOUT executing the remainder of the program
If, and only if, the correct number of command-line arguments are providedCreate six (6) variables (integer) to store the following information
Leonards and Sheldons initial shapes (2)
The number of rounds to play (1)
Counters to track Leonards and Sheldons wins (2) and the number of ties (1)
Convert Leonards and Sheldons initial shapes using the convertShape function
The initial shapes are located at indexes 1 and 2 of the command-line arguments
Use the strlwr function in to convert the initial shape string to all lowercase characters
sheldonsInitialShape = convertShape(strlwr(argv[1])); leonardsInitialShape = convertShape(strlwr(argv[2]));
Convert the number of rounds to a numeric value
The number of rounds is located at index 3 of the command-line arguments
Use the atoi function in to convert the string to a number
roundsToPlay = atoi(argv[3]);
Call the playGame function passing the appropriate values and references
Call the displayResults function passing the appropriate values
Function Descriptions
convertShapeConverts a shape name to its corresponding numeric value
Refer to the constants provided in the Recommended Constants section for more details
Use the return value of the strcmp function in to compare two strings
0 - the two strings are the same (including case)
Negative # - the first string exists (alphabetically) before the second string
Negative # - the first string exists (alphabetically) after the second string
if(strcmp(shape, "rock") == 0)
determineLeonardsNextShape Use Leonard's strategy to determine his next shape
Refer to the Player Strategies section for more details
determineSheldonsNextShapeUse Sheldon's strategy to determine his next shape
Refer to the Player Strategies section for more details
determineWinner
Determine which player won the most recent round or if the round ended in a tie
displayResults (see Example Output)
Displays Sheldons and Leonards initial shapes
Display the final result of the game (i.e., Sheldon Wins!, Leonard Wins! or Tie Game!)
Display the win count for Sheldon and Leonard, as well as the number of ties
getBetterShapeHelps Leonard choose his next shape if he lost or tied the most recent round
Refer to the Player Strategies section for more details
playGame
Play the specified number of rounds
During each round:
Determine the winner using each players current shape
Update the scores
Determine Leonard's next shape
It's important that you determine Leonard's next shape before determining Sheldon's next shape
Determine Sheldon's next shape
updateScore
Update the win count for the appropriate player or the tie count after each round
Game Rules (refer to Figure 1)
"Scissors cuts Paper, Paper covers Rock, Rock crushes Lizard, Lizard poisons Spock, Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper, Paper disproves Spock, Spock vaporizes Rock, and as it always has, Rock crushes Scissors!" - Sheldon Cooper, The Big Bang Theory
Player Strategies
Sheldon's Strategy
He selects Spock as his next shape every other round
For rounds in which Spock is his current shape
If he wins, he selects Rock as his next shape
If he ties, he selects Lizard as his next shape
If he loses, he selects Paper as his next shape
Leonard's Strategy
If he wins, he uses the same shape for the next round
If he ties, he selects the better of the two shapes that defeat his current shape
If he loses, he selects the better of the two shapes that defeat Sheldons current shape
Additional Notes
Play the game with a friend a couple of times to better understand the logic of the game
Use the constants defined in the Recommended Constants section to simplify the code
Ensure your source code conforms to the programming and commenting standards for the class
Submit the design document in a common file format (i.e., *.doc, *.docx, *.pdf, *.png, *.jpg)
Submit the project source code as a single *.c file
Submit a text capture of the compiler output as a *.txt file
Submit a text capture of the program output as a *.txt file
Submit the after-action report as a *.doc/*.docx or *.txt file
Example Output
Note 1: The text, "// Command-line Arguments:", provides the command-line arguments for each example; therefore, the text should not appear in the output of the program.
Note 2: Your program only needs to produce a single output.
Note 3: Your program should be able to reproduce the results of each example.
// Command-line Arguments: spock rock 3 Ima C Programmer Rock-Paper-Scissors-Lizard-Spock Sheldon's initial shape: spock Leonard's initial shape: rock Sheldon wins! Sheldon won 2 game(s), Leonard won 1 game(s), and they tied 1 game(s)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
