# How to use the Random statement to generate a random attack.

• March 3rd, 2013, 03:43 PM
Shzylo
How to use the Random statement to generate a random attack.
I am making a text adventure that in a stage you have to fight an enemy. I want to use the Random() method so the enemy will use a random move when it is their turn to attack.
• March 3rd, 2013, 03:55 PM
curmudgeon
Re: How to use the Random statement to generate a random attack.
Please add some "meat" to your question, enough so that we will be able to answer it intelligently, including just where you may be stuck. Here's a great article on how to ask a good question: Writing the Perfect Question by Jon Skeet
• March 3rd, 2013, 03:56 PM
Zyrion
Re: How to use the Random statement to generate a random attack.
More on the Random Class
• March 3rd, 2013, 04:16 PM
Shzylo
Re: How to use the Random statement to generate a random attack.
Quote:

Originally Posted by curmudgeon
Please add some "meat" to your question, enough so that we will be able to answer it intelligently, including just where you may be stuck. Here's a great article on how to ask a good question: Writing the Perfect Question by Jon Skeet

Better?
• March 3rd, 2013, 04:20 PM
curmudgeon
Re: How to use the Random statement to generate a random attack.
Quote:

Originally Posted by Shzylo
I am making a text adventure that in a stage you have to fight an enemy. I want to use the Random() method so the enemy will use a random move when it is their turn to attack.

So again, what have you tried? Where are you stuck?
• March 3rd, 2013, 06:05 PM
Shzylo
Re: How to use the Random statement to generate a random attack.
I want Random() to randomly pick one of the attacks, or select one of the Strings randomly from the list.

--- Update ---

Nevermind, i found out how:

Random random = new Random();
int number = random.nextInt(3);

and so on from there :P