Instructions
- 1
Open your Java programming editor and open the Java app project you want to edit. Open the source code file you want to use to create the random number.
2Initialize the random generator class. Initialization lets you set up the generator to return a number. Add the following code to the file:
Random random = new Random();
3Generate a number. You specify the range in which you want to generate a number. The range is from zero to a positive integer number. For instance, the following code generates a number between zero and five:
int number = random.nextInt(5);
4Pass the integer to the function that disables the control. For instance, the following code passes the random number to the "DisableControl" function:
DisableControl(5);
No comments:
Post a Comment