Starting from:
$24.99

$18.99

Rock, Paper, Scissors Game Solution

Write a program that let the user play the game of Rock, Paper, and Scissors against the computer. The program should work as follows.

 

1.      When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)

 

2.      The user enters his or her choice of “rock”, “paper”, or “scissors” at the key board. (You can use a menu if you prefer)

 

a.       1 means rock

b.      2 means paper

c.       3 means scissors

3.      The computer’s choice is displayed.

4.      A winner is selected according to the following rules:

a.       If one player chooses rock and the other player chooses scissors, then rock wins.

 

b.      If one player chooses scissors and the other player chooses paper, then scissors wins.

 

c.       If one player chooses paper and the other player chooses rock, then paper wins.

 

d.      If both players make the same choice, the game must be played again to determine the winner.

 

5.      After a winner is decided, it should display the winner.

 

6.      After one round, the program will ask whether or not the user wants to play again. If so, the steps 1 – 5 are repeated. If not, the program quits.

 

7.      The maximum number of rounds is 10. After 10 rounds, the program must terminate.

 

Note: your program must be user-friendly and intuitive. This is a part of your grade. In other words, even if your program does everything the problem statement states, your grade may be reduced because of difficulty to use it.

Input

 

You will use interactive I/O and File I/O in this program. All of the input must be validated. All the input and output data must be written to a file.

 

Test case

 

In this project, you are responsible to design your own test cases. Your test cases must thoroughly test every single case. I will run my test cases when I grade your project. If any of my test cases causes your project to crash, points will be deducted.

 

Use of Methods, Parameters, Modularity, Design, etc.

 

Part of your grade on this and ALL future programming projects in this course will be determined by how well you use multiple functions and parameter passing appropriately and how well you design a modular and functionally cohesive program using the principles discussed in class. Large grade point penalties can be incurred for not setting up a modular, well designed program structure. This emphasizes good program structure, design, and fundamental software engineering principles.

 

In this project, you must define and call the following 4 methods:

 

public static int UserSelection();

 

public static int ComputerSelection(Random rand);

 

public static String DecideWinner(int userChoice, int computerChoice); public static void AnnouceWinner(String winner);

 

Miscellaneous

 

Be sure to read and understand the sections in the Course Syllabus handout on general project requirements. Also be sure to study the style, documentation and formatting guidelines discussed in the Programming Style Guidelines handout and in the lecture.

 

What File To Turn In and How to Turn In Your Work using Blackboard

 

You must turn in your Java program source file which must be named as follows:

Use this format: hw5_RockPaperScissors.java

Hence file names will look something like "hw5_RockPaperScissor.java"

More products