Jump to content

Rock paper scissors game (homework)

hey guys

 

we have been given an assignment and one fo the tasks is to complete a rock paper scissors game using JAVA coding. i am fine with all details of how to write the game but the method i am using to creat the game requires a Random number gen.. i have made these before but i cannot for the life of me figure out how to generate a number between 1 and 3 (where 1 and 3 are included in the possible selection).

 

(i have checked google and cannot find anything of use)

 

Thank you for your help any of which is highly appreciated :D

SYSTEM SPECS

CPU> Intel 4790k< GPU> EVGA GTX970< SSD> Crucial MX200 250Gb< HDD> Seagate Barracuda 2Tb<
Cooling> Corsair H100i< Case> Corsair Air 540< PSU> Seasonic X-Series 650W< RAM> 8Gb Kingston HyperX<
Link to comment
Share on other sites

Link to post
Share on other sites

Sorry guys this was a false alarm i figured out how to do it on my own

SYSTEM SPECS

CPU> Intel 4790k< GPU> EVGA GTX970< SSD> Crucial MX200 250Gb< HDD> Seagate Barracuda 2Tb<
Cooling> Corsair H100i< Case> Corsair Air 540< PSU> Seasonic X-Series 650W< RAM> 8Gb Kingston HyperX<
Link to comment
Share on other sites

Link to post
Share on other sites

Generate one random number in a range 1 - 6:
 
 
Random r = new Random();
 
int n = r.nextInt(6) + 1;

------------------------------------

     ~ Live Love Code ~

------------------------------------

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×