19 Jul java programming 5
CPS 150 Programming Assignment 5: RPSLS (Rock, Paper, Scissors, Lizard, Spock)
Update the Rock, Paper, Scissors program you wrote for Lab Project 14 so that it plays RPSLS. The Rules for RPSLS are described by Dr. Sheldon Cooper on The Big Bang Theory (also quoted below), and shown in the diagram on the right.
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.
RPSLS Features (Updates):
· The user input should be text, not numerical (e.g., “rock” not 1). It should also be case-insensitive (see the Sample Run, below).
· Suggestion: use the Scanner method nextLine() instead of the Scanner method next() for user input.
· Suggestion: to minimize re-write of your existing code, “translate” the user input into one of five values (there are three in the original program);
· a good way to do this is to define and call a method static int textToNumber(String choice) .
·
· After each round, the user is prompted as to whether they want to play again (i.e., yes or no).
· Suggestion: only play again if the user enters yes; otherwise, end the game.
· Suggestion: use the Scanner method nextLine() instead of the Scanner method next() for user input.
·
· For each round, the user input of choice should be validated as one of the five valid choices; anything else causes the round to be forfeited and prompts the user as to whether they want to play another round.
· Suggestion: define a method static boolean isValid(String choice) and call it with the user choice as an if condition.
·
· You will have to add methods for the two new choices that the user can make:
· int lizardChoice(int computerChoice)
· int SpockChoice(int computerChoice)
· As with the original three methods, each of these two new methods returns one of the three named int constants PLAYER1_WINS, PLAYER2_WINS, or DRAW.
·
· You will also have to re-define (expand) the code in the original three methods rockChoice, paperChoice, and scissorsChoice to check whether the computer chose either of the two new choices (i.e., lizard or Spock).
Sample Run (user input in color):
run:
Welcome to the game of Rock Paper Scissors Lizard Spock
Here are the rules:
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
Ready? Then let’s begin!
Player 1, enter your choice ( rock, paper, scissors, lizard, Spock ): rock
OK, you chose rock
Player 2 (computer) chooses rock
It’s a draw
Play again (yes/no)? yes
Player 1, enter your choice ( rock, paper, scissors, lizard, Spock ): spock
OK, you chose spock
Player 2 (computer) chooses lizard
Lizard poisons Spock; Player 2 wins
Play again (yes/no)? yes
Player 1, enter your choice ( rock, paper, scissors, lizard, Spock ): banana <— invalid input
Invalid choice “banana”; try again.
Player 1, enter your choice ( rock, paper, scissors, lizard, Spock ): Paper
OK, you chose paper
Player 2 (computer) chooses scissors
Scissors cut paper; Player 2 wins
Play again (yes/no)? yes
Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): <— invalid input (empty string)
Invalid choice “”; try again.
Player 1, enter your choice ( rock, paper, scissors, lizard, Spock ): SCISSORS
OK, you chose scissors
Player 2 (computer) chooses paper
Scissors cut paper; Player 1 wins
Play again (yes/no)? yes
Player 1, enter your choice ( rock, paper, scissors, lizard, Spock ): lIZARD
OK, you chose lizard
Player 2 (computer) chooses scissors
Scissors decaptiate lizard; Player 2 wins
Play again (yes/no)? no
BUILD SUCCESSFUL (total time: 1 minute 30 seconds)
——————————————————————————————–
Assignment Grading (for each method):
· (Updated) Contract: 10%
· (Updated) Purpose Statement: 10%
· (Updated) Examples: 10%
· (Updated) Algorithm: 10%
(Updated) Method Code: 60%
What Do I Hand In?
Once you are done, upload the source code file (i.e., .java file) for your NetBeans project.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.