Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Project 1: Rock, Paper, Scissors. due Friday(March 1) sample output: Needs to be turned in via e-mail before class on Friday. Additionally, a printout of

image text in transcribed
image text in transcribed
Project 1: "Rock, Paper, Scissors". due Friday(March 1) sample output: Needs to be turned in via e-mail before class on Friday. Additionally, a printout of the program should be turned in in class. ROCK PAPER SCISSORS GAME Hello! Let's get started Rock, Paper, or Seissors? (R, P,S): r You chose Rock Computer chose Scissors Rock blunts Scissors! You WIN! In this project you will write a Java program that interactively plays "Rock, Paper, Scissors game with the user. This project incorporated several new concepts: methods, if-else statements and loops, constants, as well as random number generation. You: Comp SCORE: 11:0I Do you want to play some mre? (y or n): y | lf you do not remember or are unfamiliar with Rock. Rock, Paper, or Scissors? (R, P,S): r You chose Rock! Paper, Scissors" game, here's a link to a Wikipedia article Computer chose Rock! It's a draw!! sors You: Comp SCORE, I am providing you with the skeleton of the Do you want to play some more? (y or n)program: RockPaperScissors.java It has main() method already finished, you'll have to finish other methods. Rock, Paper, or Scissors? (R,P.S): t BRRRZZZT! Sorry, that entry is invalid Try again Rock, Paper, or Scissors? (R,P,S):s You chose Scissors Computer chose Paper! Scissors cut Paper! You WIN! Your program should first greet the player and then offer him/her to enter Rock, Paper, or Scissors option. The player should enter one of the three. You need to check that the player always enters one of the correct options. If she enters a wrong option you should ask her to try again. . YouComp -__ SCORE: Do you want to play some more? (y or n):Y Rock, Paper, or Scissors? (R,P.S): s You chose Scissors! Computer chose Paper! Scissors cut Paper! You WIN! .Next, the computer randomly "picks" rock, paper or scissors as well, and the program prints out the result according to the rules of the game The program should also keep the overall score and print it out after each game. After each game, the program should ask the player if she wants to continue. If the player says "yes the game continues in the same manner You : Comp SCORE: -- . Do you want to play some more? (y or n):n GAME OVER FINAL SCORE: You: Comp . SCORE:-ccc 13:0 I To the left you can see a sample output of this program WHAT DO YOU NEED TO HAVE IN YOUR PROGRAM: 1. You have five int constants (ROCK, PAPER, and SCISSORS as well as You_WIN, COMP WIN, and DRAW). (Provided to you) 2. You should have a game loop - the one that will keep going until you enter "No" when the program asks you "do you want to continue". Because the game would always be played at least one time it makes sense to make it a do - while loop. (Provided to you) 3. In fact, the entire main) method is provided to you-you don't have to change it. In addition, you are provided the skeletons of three more methods that you will have to implement according to the comments in the provided code. 4. Within a game loop, your main) is calling a method playGame0 that will be the one actually playing the game. It takes a Scanner object created in main() as a parameter (which means you don't have to create a new Scanner object every time you call playGame0). You will have to implement this method following the step described in its comments. 5. Once the method playGame() reads the input from the player and generates the computer's choice it, in turn, calls the method whoWins(0 which takes the players choice and computer's choice as input parameters, determines who wins, prints it out (with corresponding explanation, e.g. "Rock blunts Scissors. You WIN!") and returns the integer result of the game (see comments in the code) 6. Lastly, the method printScore) is called to print the current score at the end of each game. You should implement it so that the score is printed exactly as shown in the sample output above Notice that the main() keeps the overall score using variables yourscore and compScore and updates them when playGame returns the result of the game. 7. Include your first and last names together with your section number at the top of the program comments. NOTES In Java we can declare class static variables that are visible and accessible to all the methods of the class. If we also declare them final, then their value can not be changed anywhere in the program. These variables are called constants and can be very useful when we want to assign certain values to certain types of outcomes and make them easily readable. Traditionally, constants are named using all capital letters. Thus, in our program we have five constants: static final int ROCK-1, PAPER = 2, SCISSORS 3, YOU-MIN 4, COMP WIN-S, DRAW-e; Now we can say, for example: if (userInput.equals("R")) yourChoice-ROCK; Or, when deciding who wins, we can say if(yourChoice-ROcK && compChoice SCISSORS)( System.out.println("Rock blunts Scissors! You WIN!") return YOU_WIN; (Note, you might not need this exact code in your program-it just shows the use of constants)

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_2

Step: 3

blur-text-image_3

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students explore these related Databases questions