Game: Sciessor, Paper and Stone game in jave and it s source code is here

 package com.company;

import java.util.Scanner;
import java.util.Random;
public class rock_paper_scissors_game {
public static void main(String[] args) {
System.out.println("before starting the game you should know this convention");
System.out.println("Scissor=0");
System.out.println("Paper=1");
System.out.println("Rock=2");
short draw=0;
short yourCounter=0;
short compCounter=0;
for(int i=0; i<3; i++) {
Random rn = new Random();
Scanner sc = new Scanner(System.in);
System.out.println("ENTER YOUR CHOICE");
byte choice = sc.nextByte();
System.out.println("CHOICE ENTERED BY COMPUTER");
byte compRandom = (byte) rn.nextInt(3);
switch(choice) {
case 0:
if (compRandom == 0) {
System.out.println(compRandom);//
System.out.println("Draw");
draw++;
} else if (compRandom == 1) {
System.out.println(compRandom);//
System.out.println("you win");
yourCounter++;
} else {
System.out.println(compRandom);//
System.out.println("you loose");
compCounter++;
}
break;


case 1:
if (compRandom == 0) {
System.out.println(compRandom);//
System.out.println("you loose");
compCounter++;
} else if (compRandom == 1) {
System.out.println(compRandom);//
System.out.println("Draw");
draw++;
} else {
System.out.println(compRandom);//
System.out.println("you win");
yourCounter++;
}
break;


case 2:
if (compRandom == 0) {
System.out.println(compRandom);//
System.out.println("you win");
yourCounter++;
} else if (compRandom == 1) {
System.out.println(compRandom);//
System.out.println("you loose");
compCounter++;
} else {
System.out.println(compRandom);//
System.out.println("Draw");
draw++;
}
break;
default:
System.out.println("Invalid Input");

}//switch



}
System.out.println("\n");
if(yourCounter>compCounter){
System.out.println("you win the game");
}
else if(yourCounter<compCounter){
System.out.println("you loose the game");
}
else {
System.out.println("Draw Game");
}

}
}

Comments

Popular posts from this blog

priority_queue

css in phone