Created
February 13, 2011 13:19
-
-
Save chids/824679 to your computer and use it in GitHub Desktop.
Random number within range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RandomRange | |
{ | |
private final int max; | |
private final int min; | |
public RandomRange(final int min, final int max) | |
{ | |
this.min = min; | |
this.max = max; | |
} | |
public int next() | |
{ | |
return this.min + (int)(Math.random() * ((this.max - this.min) + 1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment