private static int RandomNumberGenerator(int aStart, int aEnd, Random aRandom){ if ( aStart > aEnd ) { throw new IllegalArgumentException("Start cannot exceed End."); } long range = (long)aEnd - (long)aStart + 1; long fraction = (long)(range * aRandom.nextDouble()); int randomNumber = (int)(fraction + aStart); return randomNumber; }
Friday, November 26, 2010
Random number generator
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment