CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades | Students

Assignment #8

Create the Roshambo game

Due Date: Monday of Week 4
30 points

This project uses an enumeration with a toString method, an abstract class with an abstract method that defines a player, and three classes that inherit the player class. This is an interesting project, but the logic is fairly complicated.

Console

Operation

  • The application prompts the player to enter a name and select an opponent.
  • The application prompts the player to select rock, paper, or scissors. Then, the application displays the player's choice, the opponent's choice, and the result of the match.
  • The application continues until the user doesn't want to play anymore.
  • If the user makes an invalid selection, the application should display an appropriate error message and prompt the user again until the user makes a valid selection.

Specifications

  • Create an enumeration named Roshambo that stores three values: rock, paper, and scissors. This enumeration should include a toString method that can convert the selected value to a string.
  • Create an abstract class named Player that stores a name and a Roshambo value. This class should include an abstract method named generateRoshambo that allows an inheriting class to generate and return a Roshambo value. It should also include get and set methods for the name and Roshambo value.
  • Create classes named Bart and Lisa that inherit the Player class and implement the generateRoshambo method. The Bart class should always select rock. The Lisa class should randomly select rock, paper, or scissors (a 1 in 3 chance of each).
  • Create a class named Player1 that inherits the Player class and implements the generateRoshambo method (even though it isn't necessary for this player). This method can return any value you choose.
  • Create a class named RoshamboApp that allows the player to play Bart or Lisa as shown in the console output. Rock should beat scissors, paper should beat rock, and scissors should beat paper.
  • Use the Validator class or a variation of it to validate the user's entries.

Enhancement

  • Keep track of wins and losses and display them at the end of each session.
Include in your program the following comments:
  • Name of program
  • Programmer's name
  • Current Date
  • Computer system and compiler you are using
  • Brief description of the program

Compile and run the Java program.

Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.

When you are ready, upload the java program and the gif file by clicking the link below:

Upload Assignment

I cannot grade if I don't get the files and receive your email.