FileDocCategorySizeDatePackage
RandomNos.javaAPI DocExample636Fri Mar 31 21:43:52 BST 2000None

RandomNos

public class RandomNos extends Object

Fields Summary
static final Random
r
Constructors Summary
Methods Summary
public static intbinRand()

  // a class constructor won't do the job if no instance of
  // RandomNos is called
    
    r = new Random();//not the same every time
  
  // Returns 0 or 1
    float holdR = r.nextFloat();
    if(holdR >0.5) {
      return 0;
    }
    else {
      return 1;
    }
  
public static floatfloatRand()

  //returns 0..1.0
    return r.nextFloat();
  
public static intrangeRand(int range)

  // returns a number in the range 0..range-1
    return Math.abs(r.nextInt()) % range;