home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_rand / gen_rand.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  1.8 KB  |  71 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://www.loria.fr/SmallEiffel
  11. --
  12. deferred class GEN_RAND
  13.    -- 
  14.    -- Here is the common way to use a random number generator.
  15.    -- Current implementations are MIN_STAND, STD_RAND.
  16.    --
  17.  
  18. feature {NONE} -- Creation procedures:
  19.  
  20.    make is
  21.      -- Create the generator with an automatic setting
  22.      -- of `seed_value' (Automatic setting is done using
  23.      -- internal address of Current for example).
  24.       deferred
  25.       end;
  26.  
  27.    with_seed(seed_value: INTEGER) is
  28.      -- Create the generator with an explicit `seed_value'.
  29.       deferred
  30.       end;
  31.  
  32. feature
  33.    
  34.    next is
  35.      -- Compute next random number in sequence.
  36.       deferred
  37.       end;
  38.  
  39. feature -- No modifications :
  40.    
  41.    last_double: DOUBLE is
  42.      -- Look at the last computed number.
  43.      -- Range 0 to 1;
  44.       do
  45.      Result := last_real.to_double;
  46.       ensure
  47.      Result > 0 and Result < 1
  48.       end;
  49.    
  50.    last_real: REAL is
  51.      -- Look at the last computed number.
  52.      -- Range 0 to 1;
  53.       deferred
  54.       ensure
  55.      Result > 0 and Result < 1
  56.       end;
  57.    
  58.    last_integer(n:INTEGER):INTEGER is
  59.      -- Look the last computed number.
  60.      -- Range 1 to `n'.
  61.       require 
  62.      n >= 1
  63.       deferred
  64.       ensure
  65.      1 <= Result and Result <= n
  66.       end;
  67.  
  68. end -- GEN_RAND
  69.  
  70.  
  71.