Your CSCI 1301 course project is to implement, in stages, a computerized version of the game Rock, Paper, Scissors, Lizard, Spock, as popularized in the television show The Big Bang Theory.
The Rules of the Game
Or, if you prefer:
There is a “Project” folder in the iCollege dropbox where you are to submit every version of your program as a .java file. Screenshots of execution are not required for each version; those where they are needed will be indicated along with the description of that version.
Versions of the program
- Read in each player’s move as a String value, then write it back out in a descriptive statement, using console-based input/output (i.e. a Scanner object and System.out.println()).
- Read in each player’s move as a String value, then write it back out in a descriptive statement, using dialog/message box input/output via the JOptionPane class methods.
- Determine and print out which player won the game using only if statements with no else clauses allowed. You may, however, use the && operator in your conditions, i.e.
if (player1.equals(“rock”) && player2.equals(“scissors”)
- Determine and print out which player won the game using if –else statements (multiway and/or nested), but without using Boolean operators.
- (SCREENSHOTS REQUIRED) Determine and print out which player won the game using if –else statements and Boolean operators, making this code as efficient as possible. Also, add input validation with appropriate error messages to your program, being as specific as possible with your error messages.
- Use a for loop to allow the players to play ten rounds of the game. Keep track of how many rounds each player wins, and how many rounds end in a tie. At the end of the game, display how many rounds player 1 won, how many player 2 won, and how many times they tied.
- (SCREENSHOTS REQUIRED)Replace your existing one-time input validation with a repeated input validation that has the user keep inputting their move until they put in a valid one. Also, replace the previous for loop to allow the players to play ten rounds of the game with a loop that continues playing the game until the user(s) indicate they are ready to quit.For extra credit:
- limit the number of attempts they have to get their move right before you kick them out of the program.
- have the users indicate they want to quit the game without using any additional input statements.
- Modularize your program as follows:
- Make the input & validation section into a method that returns a player’s validated move. Call the method twice, once to validate each player’s move.
- Move the code that prints the final results into a void method, using the numbers of each player’s wins and the number of ties as arguments to the method. Call it appropriately in the main method.
- For additional consideration, create any additional methods that you deem appropriate in your program to carry out specific tasks that you are doing.
- Note: do NOT, under any circumstances, use any variables defined outside of a method (a.k.a. global variables). Your submission will be rejected with a scathing comment about reading and following directions.
- (SCREENSHOTS REQUIRED) Add an array to your program to store the winning move for each round of the game. Start by assuming there are 10 rounds to the game; be prepared to expand the array if needed (put this code in a method of its own). Output the array values in your results method, nicely labeled.
- (SCREENSHOTS REQUIRED) Modify your array from step 9 to be a two-dimensional array, saving Player 1’s move in the first column, Player 2’s move in the second column, and the winner in the third column. Again, output the array values in your results method, nicely labeled.
- (SCREENSHOTS REQUIRED) Add file input/output to your program as follows:
- When the match is over, write your array from step 10 to a text file, with each round on a single line of text.
- Add the ability to let the players choose at the beginning of the match to either start a brand new match or continue a previous match. If they choose to continue a previous match, get the file name from them and read in the data in the file into the results array before continuing the match.
- (SCREENSHOTS REQUIRED) Add an option to your program to either let two humans play, or to let one human play against the computer. This requires modifying the code where the second player’s move is read in to instead randomly generate a move for the computer using the Random class of package java.util. In this case, error checking should NOT be required for that move. All other parts of the code should remain the same.
Although we are not covering the last three topics in this course, I have left them in here for the sake of completeness.
- Add proper exception handling for all possible IOExceptions to your program.
- Break up your current program into two instance classes, one for a Move and one for a Player, plus the application program itself. The Move class should contain one data member, the move itself, plus all the necessary code to create/access/modify/compare a Move object. The Player class should contain two data members, one the current Move and the other the number of wins currently, as well as the necessary code to create/access/modify/compare a Player object. Your application program should create two Player objects and then use their methods to play the game.
- Add a graphical user interface (GUI) to your program. It should include in the window a way for each of the two players to enter their move for the current round, a “Determine Winner” button to actually determine which player wins the round, and something showing how many games Player 1 has won, how many Player 2 has won, and how many games were tied. You will also need a “Quit the Game” button. Bonus points if your player move entry is properly implemented with either radio button groups or drop-down lists instead of text fields. All other functionality of your program should remain intact.