Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

28.17 Programming Project: Go See the Doctor C++ Program Specifications C++ Write a program to play an automated game of Apple, Doc, Horse. Two players

28.17 Programming Project: Go See the Doctor C++

Program Specifications C++

Write a program to play an automated game of Apple, Doc, Horse. Two players make one of three hand signals at the same time. Hand signals represent an apple, a doc, or a horse. Each combination results in a win for one of the players. Apple keeps doctor away, doc cures horse, and horse eats apple. A tie occurs if both players make the same signal. Use a random number generator of 0, 1, or 2 to represent the three signals. Note: this program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. This based on current best practices in software development that leverages iterative or repeating development processes that produce working code on a regular cycle vs trying produce working code only at the end of the project. for more information visit: Incremental Development

Random Number Generators

Random number generators are tricky. Random number generators are implementation specific. So you will need to use your debugger to trace the decisions in your code to see if it's making the correct decisions. Your program could be working, but the output will differ on your computer. Once you put it on the Zybook, the results will be the same as the test cases if you wrote the code properly.

Project Steps

Step 0. Read starter template and do not change the provided code. Integer constants are defined for APPLE, DOC, and HORSE. A Random object is created and a seed is read from input and passed to the Random object. This supports automated testing and creates predictable results on this platform that would otherwise be random across platforms.

Step 1 (2 pts). Read two player names from input (string). Read number of rounds from input. Continue reading number of rounds if value is below one and provide an error message. Output player names and number of rounds. Submit for grading to confirm 2 tests pass. Ex: If input is:

3 Anna Bert -3 -4 4 

Sample output would start with (only focus on the start for this test case):

Rounds must be > 0 Rounds must be > 0 Anna vs Bert for 4 rounds 

Step 2 (2 pts). Generate random values (0 - 2) for player 1 followed by player 2 by calling rand() % 3. Continue to generate random values for both players until both values do not match. Output "Tie" when the values match. Submit for grading to confirm 3 tests pass.

Ex: If input is:

10 Anna Bert 1 

Sample output is:

Anna vs Bert for 1 rounds Tie Tie Bert wins with horse Anna wins 0 and Bert wins 1 

Step 3 (3 pts). Identify winner for this round and output a message. Apple keeps doc away, horse eats apple, and doc cures horse. Submit for grading to confirm 6 tests pass. Ex: If input is:

39 Anna Bert 1 

Sample output is:

Anna vs Bert for 1 rounds Tie Tie Anna wins with doc Anna wins 1 and Bert wins 0 

Step 4 (3 pts). Add a loop to repeat steps 2 and 3 for the number of rounds. Output total wins for each player after all rounds are complete. Submit for grading to confirm all tests pass. Ex: If input is:

82 Anna Bert 3 

Sample output is:

Anna vs Bert for 3 rounds Bert wins with apple Tie Bert wins with horse Bert wins with apple Anna wins 0 and Bert wins 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions