Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

we cannot use break, goto or continue. thank you. Week 5 practice problems X Lab_6_RPS.pdf validationExamples.mp4 - GX mod_resource/content/10/Lab_6_RPS.pdf 1 / 2 110% + CS

image text in transcribed
image text in transcribed
image text in transcribed
we cannot use break, goto or continue. thank you.
Week 5 practice problems X Lab_6_RPS.pdf validationExamples.mp4 - GX mod_resource/content/10/Lab_6_RPS.pdf 1 / 2 110% + CS 161 Programming Lab 6 For this exercise you will create a version of the Rock, Paper, and Scissors game that is played against the computer. The program will use a number of functions as listed below. The computers move will be randomly generated. Problem description While this program will be an introduction to using functions, it will also be a review of data validation and loops. In addition to using functions, you will be using nums as described in Moodle. For this, as in all assignments, you are expected to follow the course programming style guidelines Program Functionality The game must use enums to represent both the user and computer moves. Each function should have at least one comment. Constants should be used where appropriate. Display a clear set of instructions to the user Input R, P, or S from the user. Validate the input, if incorrect prompt the user to re-enter until correct. Either upper or lower case is ok. Get a random computer move. Display clear output describing the outcome of the game including the user's pick, the computer's pick and the winner. Ask the user if they would like to play again and repeat the entire game again as necessary. Required Functions At a minimum the program should have the following functions: displayinstructions o no parameters o tells the user how to play the game o no return values . . O i 1/2 110% + Required Functions At a minimum the program should have the following functions: displayinstructions no parameters o tells the user how to play the game no return values O o getMove O no parameters get a move from the user and validate (R, r, P. p, S, or ] return appropriate enum (Rock, Paper, Scissors) getComp Move 0 no parameters o generate a random value 0, 1, or 2 o return appropriate enum (Rock, Paper, Scissors) getWinner O two parameters (user move and computer move as enums) This work by Jim Bailey is licensed under a Creative Commons Attribution 4.0 Interna 0 0 0 determine winner as described below output the results no return values O Week 5 practice problems Lab_6_RPS.pdf validationExamples.mp4 - G mod_resource/content/10/Lab_6_RPS.pdf 21 21 110% OOO determine winner as described below o output the results no return values . playAgain no parameters O ask the user if they want to play again valid the result (y) return true for y, false for n 0 Suggestions Read the document on enums before starting. Think about how to pass a parameter as an enum (hint, it is just like passing an int, but using the name of the enum). Since both the player's move and the computer's move are in enums, it is possible to use a simple series of if statements to determine the winner. if (playerMove > computer Move) player wins else if (player Move - Rock && computer Move == Scissors) player wins else if (playerMove la computerMove) computer wins else the game is a tle. W

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions