Coders Packet

Rock-Paper-Scissors-Game Using Java

By Rajesh Kolipaka

It is a simple game . In this game , the user chooses a choice of Rock or Paper or Scissors to compete with System.

Programming Language used: JAVA

 Aim of the program:

 Let the user choose a choice of Rock or Paper or Scissors to play with the System.

Functionality:

-->System will randomly generate an integer either 1 or 2 or 3 which represents Rock, Paper, and Scissors respectively.

-->The program prompts the user to enter a choice.

-->Reports the user whether WIN or LOSE or DRAW based on choices of both User and System.

-->Repeat the game until the user ends.

 About classes in the packet :

 Our code contains two classes:

1) Rock_Paper_Scissors_game

2) Main

Rock_Paper_Scissors_game class:

This class contains two methods:

1) game(): It is the important method in our packet because it contains most of the rock-paper-scissors game code.

2) display(): It is used to display the choice chosen by the System and User.

Main class:

In this class we will create an object to the Rock_Paper_Scissors_game class and using that object we will call the game() method.

Note: In our program, we have import Random module from the util package i.e. import java.util.Random; 

 

Output:

output

Download Complete Code

Comments

No comments yet