/tutorial/random/example2.e

http://github.com/tybor/Liberty · Specman e · 31 lines · 27 code · 4 blank · 0 comment · 0 complexity · 41f8d7b046b7a761221db820cf28cf0a MD5 · raw file

  1. class EXAMPLE2
  2. create {ANY}
  3. main
  4. feature {}
  5. main
  6. local
  7. count: INTEGER
  8. do
  9. io.put_string("Using the PRESS_RANDOM_NUMBER_GENERATOR random number generator.%NHow many numbers? ")
  10. io.read_integer
  11. count := io.last_integer
  12. from
  13. until
  14. count = 0
  15. loop
  16. random_generator.next
  17. io.put_real(random_generator.last_real)
  18. count := count - 1
  19. io.put_string("%N")
  20. end
  21. end
  22. feature {}
  23. random_generator: RANDOM_NUMBER_GENERATOR
  24. once
  25. create {PRESS_RANDOM_NUMBER_GENERATOR} Result.make
  26. end
  27. end -- class EXAMPLE2