Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Download - Green Lantern 2011
Project - Rock, Paper, Scissor Game EmptySun Sep 25, 2011 4:47 pm by Admin

» Download - Shark Night 3D
Project - Rock, Paper, Scissor Game EmptySun Sep 25, 2011 4:41 pm by Admin

» Download - Apollo 18
Project - Rock, Paper, Scissor Game EmptyWed Sep 21, 2011 6:37 am by Admin

» [REMODELLED] PSP E1000 - REVAMPED
Project - Rock, Paper, Scissor Game EmptyMon Sep 19, 2011 9:56 am by Admin

» PS VITA IS OFFICIALLY REGION FREE!!
Project - Rock, Paper, Scissor Game EmptyMon Sep 19, 2011 9:49 am by Admin

» Manga - Popcorn Avatar
Project - Rock, Paper, Scissor Game EmptyMon Sep 19, 2011 9:11 am by Admin

» [UPCOMING SOON] Assassin's Creed - Revelations
Project - Rock, Paper, Scissor Game EmptyMon Sep 19, 2011 8:44 am by Admin

» Assassin's Creed 2
Project - Rock, Paper, Scissor Game EmptyMon Sep 19, 2011 8:26 am by Admin

» Assassin's Creed
Project - Rock, Paper, Scissor Game EmptyMon Sep 19, 2011 6:47 am by Admin

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

Admin

Admin
Investor Persona
File name: rps4.java

Code:


import java.io.*;
import java.util.*;
public class rps4{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


    int choice;
    Random r=new Random();
    int x=0;

    do{   

    System.out.println("Choose: ");
    System.out.println("[1] Rock");
    System.out.println("[2] Paper");
    System.out.println("[3] Scissor");
    System.out.println("  ");

    choice = Integer.parseInt(br.readLine());
    int ai=r.nextInt(4);   
   
   

    if((choice==1)&&(ai==2)){
       
       
        System.out.println("Player vs Computer");
        System.out.println(" Rock  ::  Paper");
        System.out.println("  ");
        System.out.println("You Lose!");
       
       
        }

    else if((choice==1)&&(ai==3)){
       

        System.out.println(" Player vs Computer ");
        System.out.println("  Rock  :: Scissor ");
        System.out.println(" ");
        System.out.println("You Win!");
       

        }


    else if((choice==2)&&(ai==3)){
               

        System.out.println(" Player vs Computer");
        System.out.println(" Paper  :: Scissor");
        System.out.println("  ");
        System.out.println("You Lose");
       

        }

    else if((choice==3)&&(ai==1)){
       

        System.out.println(" Player  vs Computer ");
        System.out.println(" Scissor ::  Rock ");
        System.out.println(" ");
        System.out.println("You Lose!");
       

        }

    else if((choice==3)&&(ai==2)){
       

        System.out.println(" Player  vs Computer ");
        System.out.println(" Scissor ::  Paper ");
        System.out.println(" ");
        System.out.println("You Win!");
       

        }


    else if((choice==2)&&(ai==1)){
       

        System.out.println(" Player  vs  Computer ");
        System.out.println("  Paper  ::  Rock ");
        System.out.println("  ");
        System.out.println("You Win");
       

        }

    else if((choice==1)&&(ai==1)){
       

        System.out.println(" Player  VS  Computer ");
        System.out.println("  Rock  ::    Rock  ");
        System.out.println("It's Draw!!");
       
        }

    else if((choice==2)&&(ai==2)){
       

        System.out.println(" Player  vs  Computer");
        System.out.println(" Paper  ::  Paper");
        System.out.println("  ");
        System.out.println("It's Draw!!");
       
        }

    else {
       

        System.out.println(" Player  vs  Computer");
        System.out.println(" Scissor ::  Scissor");
        System.out.println("  ");
        System.out.println("It's Draw!!");
               
        }

        x++;} while(x<=3);
    }



}
   



Display Results:

[1] Rock
[2] Paper
[3] Scissor

Input:


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

As this project show you a simple game, I implement a Computer AI that will allow him to randomize a number from 1-3. Therefore, it is up for the user to choose.

Once the User chooses, it then tries to measure the conditions programmed and display the result.

https://advatar.forumotion.com
Share this post on: reddit

No Comment.

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

 

Free forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com