home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 08 / Question.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-09-08  |  530 b   |  19 lines

  1. import java.util.Random;
  2.  
  3. class Question implements SharedConstants {
  4.    Random rand = new Random();
  5.  
  6.    int ask() {
  7.       int var1 = (int)((double)100.0F * this.rand.nextDouble());
  8.       if (var1 < 30) {
  9.          return 0;
  10.       } else if (var1 < 60) {
  11.          return 1;
  12.       } else if (var1 < 75) {
  13.          return 3;
  14.       } else {
  15.          return var1 < 98 ? 4 : 5;
  16.       }
  17.    }
  18. }
  19.