CS 160 - Programming Concepts and ApplicationsSummer II 2018 - Lab 4B - RPS: MultifileQuick Links: Canvas | John Cabot | Piazza | zyBooks |
|
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |
This lab is due by Tuesday, July 17, 2018, 11:59 PM. Make a copy of Lab3D's main.cpp and place it as the starting point for Lab4B. Rock Paper Scissors Part VAt the end of Lab3D, we had a fully functioning rock-paper-scissors game that allowed the user to play multiple games. Now we want to reorganize our code structure to make use of functions to simplify our code. ConceptsThe focus of this lab is on one concept: FUNctions. Working with Data
Since we are now using functions, our int main() { char playAgain = 'Y'; int numWins = 0, numTies = 0, numLosses = 0; do { char userChoice = getUserChoice(); char compChoice = generateComputerChoice(); int gameResult = determineResult( userChoice, compChoice ); cout << choiceToText( userChoice ) << " " << gameOutcomeAsText( gameResult ) << " " << choiceToText( compChoice ) << endl; incrementTotals( gameResult, numWins, numTies, numLosses ); cout << "Do you want to play again? (Y or N) "; cin >> playAgain; } while( playAgain == 'Y' ); cout << "You won " << numWins << " game(s)." << endl; cout << "You lost " << numLosses << " game(s)." << endl; cout << "You tied " << numTies << " game(s)." << endl; return 0; } InstructionsIn order to follow incremental development and have our program be able to compile, you should first create "function stubs" that have the input/output specified but no logic inside the function. Below are descriptions of each function that you need to implement stating the name, input, and output of each function.
Lab SubmissionYou will submit your solution to this lab with the rest of Set4. Detailed instructions for doing this are posted in Assignment 4. This lab is due by Tuesday, July 17, 2018, 11:59 PM. | |
Last Updated: 07/05/18 11:27
|