Design and implement a program which plays a game of rock, paper, scissors with extrasteps.
09/04/2020 Mar 27: PA4 (due Friday, Apr 10, 11:59pm) https://canvas.jmu.edu/courses/1700186/assignments/11340908 1/5 Mar 27: PA4 (due Friday, Apr 10, 11:59pm) Due Friday by 11:59pm Points 100 Available after Mar 23 at 8am PA 4 - Rock, Paper, Scissors, Fire, Air, Water, and Sponge Objectives The following skills are addressed in completing this assignment. Writing java code to create an attractive user interface Creating and using your own classes Using selection structures Using repetition structures Decomposing a complex problem in a top-down fashion Following a "style guide" READING AND FOLLOWING DIRECTIONS!!!!! Deliverables This assignment requires you to modify and submit a program. The program should be submitted to AutoLab by 11:59pm, Friday, 10 April. Note: any assignments that do not include the Acknowledgments section as specified in the Style Guide will receive a 25% deduction. This acknowledgment should appear in all java files submitted. Speci�cations Design and implement a program which plays a game of Rock, Paper, Scissors . We will be implementing a more complicated version of this well-known game. The basic rules for the game can be found here (http://www.umop.com/rps7.htm) . Your version will be an adaptation of the basic game as outlined in the site above. The game consists of 2 players, a human player and a computer player. The players alternate turns, beginning with the human player. During each turn, the players take a series of "shots." When a player "shoots" a gesture, s/he randomly chooses a gesture representing one of the following: Rock, Paper, Scissors, Fire, Air, Water, and Sponge. While the gestures are chosen simultaneously, only the player who controls the current turn can accumulate points. Each gesture "beats" three (3) other gestures and is "beaten by" the other three (3) gestures: ROCK pounds out FIRE, crushes SCISSORS & SPONGE. FIRE melts SCISSORS, burns PAPER & SPONGE. SCISSORS swish through AIR, cuts PAPER & SPONGE. SPONGE soaks PAPER, uses AIR POCKETS, absorbs WATER. http://www.umop.com/rps7.htm 09/04/2020 Mar 27: PA4 (due Friday, Apr 10, 11:59pm) https://canvas.jmu.edu/courses/1700186/assignments/11340908 2/5 PAPER fans AIR, covers ROCK, floats on WATER. AIR blows out FIRE, erodes ROCK, evaporates WATER. WATER erodes ROCK, puts out FIRE, rusts SCISSORS. The rules for the game are as follows: 1. The player controlling the current turn gets one (1) point for each winning "shot." 2. If the player controlling the current turn loses a shot, then control turns over to the opposing player. 3. If both players "shoot" the same gesture, then the player controlling the current turn loses all points accumulated during the turn (but not during the game) and turns control over to the opposing player. 4. The first player to accumulate 20 or more points wins. Your program must be built using the following four classes: RPS7.java (https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7.java) RPS7Game.java (https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7Game.java) RPS7Player.java (https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7Player.java) RPSGesture.java (https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7Gesture.java) Note: The RPS7Gesture class has been modified to allow testing. Specifically the following changes have been made: 1. A Random object has been declared at the class level. This means you will need to instantiate it in each of the 2 constructors. 2. In the default constructor you will need to instantiate the Random object and assign the gesture variable to some initial nonsense value (0 or -1, for example). In the overloaded constructor (explicit value constructor), you will assign the value of the incoming parameter to the gesture variable. You will not use this in your program, but I will use it when testing your solution. You must write the methods as specified in each of the attached java files. You may add to these classes if you find it necessary, but aside from adding finals here and there, you should not need to add instance data or public methods to any of these classes. You will need to add private helper methods to RPS7Game.java . The program must conform to the following specifications. The game must begin with a welcome message along with a brief explanation of the game. The human player must be named "Human". The computer player must be named "Computer." The first player to shoot must be the human. The gesture "shot" by either the human or the computer player must be randomly selected (don't ask the user for a value). A turn for both the human and computer player consists of "shots (as defined above). If both players "shoot" the same gesture, the turn ends, and the current player loses all points for the turn. https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7.java https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7Game.java https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7Player.java https://users.cs.jmu.edu/nortonml/cs149/pas/pa04/RPS7Gesture.java 09/04/2020 Mar 27: PA4 (due Friday, Apr 10, 11:59pm) https://canvas.jmu.edu/courses/1700186/assignments/11340908 3/5 At the start of each players turn (both the human and the computer), a blank line should be printed followed by a line containing the player's name and score. The line should be in the following form (but with the appropriate name and score filled in). Player: Human (Total Points: 11) At the end of a players turn, a line identical to the one above should again be printed, although this time not preceded by a blank line. Before each human "shot", the human should be prompted with the following string (preceded by a TAB character and ending with a space, but not terminated with a newline). Take shot (Y/N)?: The program should validate that the user has entered "Y" or "N" (upper or lower case). The turn should end if the user responds with "N" (or "n"). If the user enters "Y" (or "y"), the turn should continue. (The program should ignore white space). There should be no prompting before each "shot" of the computer player. The computer player's turn ends after it has accumulated 4 or more points during that turn. After each winning "shot" (for either player), the program should output a line in the following form (preceded by a TAB character and terminated by a newline). ROCK beats SCISSORS (This Turn: 2, Total: 5) (In the example above, the user would have earned a total of 2 points during the current turn - including the current "shot", and 3 points during previous turns.) After each losing "shot" (for either player), the program should output a line in the following form (preceded by a TAB character and terminated by a newline). ROCK beaten by PAPER: Forfeit turn (This Turn: 2, Total: 5) (In the example above, the user would have earned 2 during prior shots during this turn, and 3 points in previous turns.) If both players "shoot" the same gesture, then, the program should output a line in the following form (preceded by a TAB character and terminated by a newline). ROCK = ROCK: Forfeit turn and points (This Turn: 0, Total: 3) (In the example above, the user would have lost the 2 points previously earned during this turn, but keeps the 3 points from previous turns.) When a player wins, the program should print out a line of the following form (preceded and terminated by a newline). The winner is: Computer A sample session (at least the beginning of one) is shown below. 09/04/2020 Mar 27: PA4 (due Friday, Apr 10, 11:59pm) https://canvas.jmu.edu/courses/1700186/assignments/11340908 4/5 Welcome to the Extended Version of Rock Paper Scissors Player: Human (Total Points: 0) Take shot (Y/N)?: Y SPONGE = SPONGE: Forfeit turn and points (This turn: 0, Total: 0) Player: Human (Total Points: 0) Player: Computer (Total Points: 0) WATER beats ROCK (This turn: 1, Total: 1) FIRE beats PAPER (This turn: 2, Total: 2) AIR = AIR: Forfeit turn and points (This turn: 0, Total: 0) Player: Computer (Total Points: 0) Player: Human (Total Points: 0) Take shot (Y/N)?: y WATER beaten by PAPER: Forfeit turn (This Turn: 0, Total 0) Player: Human (Total Points: 0) Player: Computer (Total Points: 0) SCISSORS beats PAPER (This Turn: 1, Total: 1) SPONGE beaten by SCISSORS: Forfeit turn (This Turn: 1, Total: 1) Player: Computer (Total Points: 1) Player: Human (Total Points: 0) Take shot (Y/N)?: Y SCISSORS beats PAPER (This turn: 1, Total: 1) Take shot (Y/N)?: y FIRE beats PAPER (This turn: 2, Total: 2) Take shot (Y/N)?: y FIRE beaten by WATER: Forfeit turn (This Turn: 2, Total 2) Player: Human (Total Points: 2) Procedure Some of the methods to be written are quite small and simple. For the RPS7Gesture methods, do not get confused by other aspects of the game. The RPS7Gesture methods just deal with aspects of a single gesture (including how to compare it with another gesture). The RPS7Game class is the most complicated of the classes. Here is where the game is actually played. The main method in the RPS7 class will call the play method of the RPS7Game . This will get the game started. This method should only contain the most general logic for the game. Detailed logic for various aspects of the game should be handled in separate (and private) methods. Each method should only be concerned with the details of each individual action. For example, the shoot method in RPS7Player implements a single "shot" - that is, a gesture is randomly chosen (you will use the setGesture() method of RPS7Gesture for this). You should only be thinking about what needs to be done in a single turn while you are writing this method. 09/04/2020 Mar 27: PA4 (due Friday, Apr 10, 11:59pm) https://canvas.jmu.edu/courses/1700186/assignments/11340908 5/5 Evaluation I will evaluate your program as follows: 1. Functionality of RPS7Player and RPS7Gesture and Checkstyle for all programs (AutoLab score): 50% 2. Style (adherence to the program requirements and style guide not checked by Checkstyle): 10%. 3. Organization (extent to which you have broken the problem down into layers) in RPS7Game : 20%. 4. Functionality of the RPS7Game class (20%).