Question
use Scanner Application Assignment 2 - Moropinzee The purpose of this assignment is to assess your understanding of conditional and iterative operations, string comparison, and
use Scanner Application
Assignment 2 - Moropinzee
The purpose of this assignment is to assess your understanding of conditional and iterative operations, string comparison, and input validation by creating a game that is a little twist on the classic rock-paper-scissors game called monkey-robot-pirate-ninja-zombie (AKA Moropinzee).
Here are the rules for winning:
Monkey fools Ninja
Monkey unplugs Robot
Robot chokes Ninja
Robot crushes Zombie
Pirate drowns Robot
Pirate skewers Monkey
Ninja karate chops Pirate Ninja decapitates Zombie Zombie eats Pirate Zombie savages Monkey Nobody wins
If youve never played rock-paper-scissors before, stop by the office and we can play a game! Or you can just Google it!
Task
Write an application to create the monkey-robot-pirate-ninja-zombie game described above. Algorithm
Write an algorithm for your application based on the above description. This algorithm MUST be written as comments at the top of your application along with your name, course, assignment, and due date.
Code AFTER you finish your algorithm, start working on your applications code.
1.NameyourclassAssignment2 (M(e.ign.e,mwioneulwdobueld:TbheomJopnseosJnAAssAigssnimgnemnte2nt2) 2. AllowthegametorepeatuntiltheuserrespondsnotoWouldyouliketoplayagain(seestep5) 3. This is a 2 player game. Ask each player for their choice. That is:
(a) Ask player 1 for their selection, an int from 1 - 5 to represent Monkey, Robot, Pirate, Ninja or Zombie, respectively. Your prompt must match the following:
Player 1 enter a number 1-5 for Monkey, Robot, Pirate, Ninja, or Zombie:
(b) Validate that the value entered was in the correct range. If not, ask the user to reenter the choice. Your prompt must match the following:
Invalid choice, Player 1. Enter a number 1-5:
(c) Repeat these steps for Player 2. The prompts must be the same, replacing Player 1 with Player 2.
Once a valid choice has been provided by both players, determine a winner based on the criteria given in
the description.
Your output for the winner must match the following:
Monkey fools Ninja. Player 1 wins!
(i.e., win condition. player xx wins!) where xx is the player who won the match and win condition is one of the 11 conditions listed above under which the player won.
If there was no winner (i.e., the last rule for winning), your output must match the following:
Nobody wins
Ask if they would like to play again. Your prompt must match the following: Would you like to play again? The response given here must be a String, even if the value is YES", no", Yes", n" or Y.
If they answer yes, or any variation therein, the game repeats and quits otherwise.
Test and run your application. You may use the sample game play below. Remember that a submission
that does not compile will receive a 0.
Take a screenshot of your successful run.
Deliverables Submit the following files to the appropriate dropbox:
your Java source file (i.e., the one with the .java extension) your screenshot
A sample playthrough of the game is on the next page.
NOTE: PROMPTS AND OUTPUT MUST BE EXACTLY THE SAME AS THE SAMPLE. This includes using println for ALL output.
-2-
Sample Heres a sample game play. User input in bold
Note: The prompt to enter a valid choice should repeat until the user has entered a valid choice, not just once.
Player 1 enter a number 1-5 for Monkey, Robot, Pirate, Ninja, or Zombie:
0
Invalid choice, Player 1. Enter a number 1-5:
1
Player 2 enter a number 1-5 for Monkey, Robot, Pirate, Ninja, or Zombie:
6
Invalid choice, Player 2. Enter a number 1-5:
4
Monkey fools Ninja. Player 1 wins! Would you like to play again?
yes
Player 1 enter a number 1-5 for Monkey, Robot, Pirate, Ninja, or Zombie:
3
Player 2 enter a number 1-5 for Monkey, Robot, Pirate, Ninja, or Zombie:
5
Zombie eats Pirate. Player 2 wins! Would you like to play again?
no
GAME OVER!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started