In the game Rock-Paper-Scissors, two people (in secret) select on of the three items (Rock, Paper, or Scissors). They compare their selection. Rock beats Scissors, Paper beats Rock, Scissors beats Paper. If they select the same item, it’s a tie.For this assignment, I’d like for you to make your own version of the game with your own set of three items. They could be “dogs, cats, gerbils” or “canoeing, rafting, kayaking” or “planes, trains, and automobiles”. For whatever three items you pick, you have to select one item to beat another item for all three items (much like Rock-Paper-Scissors). It doesn’t have to make sense. Why does paper beat rock, anyway? Don’t answer that.You’ll need to present a menu to allow the user to select their item and you’ll need to have the computer to randomly select an item. (This will require the Random class.)After each item is selected, determine who won (or if there is a tie because you both picked the same item). You’ll need variables to keep track of the results. The results should be displayed after every round. (See my example.)Also after every round, you should ask the user if they would like to continue.When you are done, you should refactor your code using NetBean’s “Introduce Method” feature to break the game into private helper methods. The final source code should be a readable document.This is a variation on problem 17 on page 317 in the textbook. Like the textbook, I use the Random class to select a number from 1 to 3 for the computer’s selection.In fact, I am going to provide my entire main method. Your code should be as readable as mine.public static void main(String[] args) {
String response = “yes”;Scanner keyboard = new Scanner(System.in);
Random rng = new Random();greetTheUser();
displayTheRules();while (“yes”.equals(response.toLowerCase())) {
int cpuChoice = getCPUChoice(rng);diplayTheItemChoices();
int userChoice = getUserChoice(keyboard);displayTheComputerChoice(cpuChoice);
displayWhoWon(userChoice, cpuChoice);
response = askUserIfTheyWouldLikeToPlayAgain(keyboard);
}displayClosing();
}Name your project FirstnameLastnameAssignment9Have your program do the following.Your source code must include the following documentation:Welcome to the game of Dog-Cat-Gerbil.
Gerbil beats Cat.
Cat beats Dog.
Dog beats Gerbil.
Let’s play! Enter a guess:
1: Dog
2: Cat
3: Gerbil
1
The computer picked cat.
You won!
Should we play again? [Yes]
yes
Let’s play! Enter a guess:
1: Dog
2: Cat
3: Gerbil
2
The computer picked gerbil.
Computer won.
Should we play again? [Yes]
yes
Let’s play! Enter a guess:
1: Dog
2: Cat
3: Gerbil
3
The computer picked cat.
Computer won.
Should we play again? [Yes]
no
Thanks for playing!To turn in your application, find the folder containing your entire project (not the folder with the “java” file), zip it up, and turn it in.
Assignment, CS2070, Do-It-Yourself, Rock-Paper-Scissors, solved
[SOLVED] Cs2070 assignment 9: do-it-yourself rock-paper-scissors
$25
File Name: Cs2070_assignment_9__do_it_yourself_rock_paper_scissors.zip
File Size: 518.1 KB
Reviews
There are no reviews yet.