PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/random/example3.e

http://github.com/tybor/Liberty
Specman e | 46 lines | 41 code | 5 blank | 0 comment | 3 complexity | 7f26f923115b34f7c9ee372490797b5a MD5 | raw file
 1class EXAMPLE3
 2
 3insert
 4   ARGUMENTS
 5
 6create {ANY}
 7   main
 8
 9feature {ANY}
10   main
11      local
12         random_number_generator: RANDOM_NUMBER_GENERATOR; seed, count: INTEGER
13      do
14         if argument_count < 2 then
15            io.put_string("Usage: ")
16            io.put_string(argument(0))
17            io.put_string(" <seed> <count> [minimal|press]%N")
18            die_with_code(exit_failure_code)
19         end
20         seed := argument(1).to_integer
21         count := argument(2).to_integer
22         if argument_count > 2 then
23            if argument(3).same_as("press") then
24               create {PRESS_RANDOM_NUMBER_GENERATOR} random_number_generator.with_seed(seed)
25               io.put_string("Using PRESS_RANDOM_NUMBER_GENERATOR.%N")
26            else
27               create {MINIMAL_RANDOM_NUMBER_GENERATOR} random_number_generator.with_seed(seed)
28               io.put_string("Using MINIMAL_RANDOM_NUMBER_GENERATOR.%N")
29            end
30         else
31            create {PRESS_RANDOM_NUMBER_GENERATOR} random_number_generator.with_seed(seed)
32            io.put_string("Using default PRESS_RANDOM_NUMBER_GENERATOR.%N")
33         end
34
35         from
36         until
37            count = 0
38         loop
39            random_number_generator.next
40            io.put_real(random_number_generator.last_real)
41            count := count - 1
42            io.put_string("%N")
43         end
44      end
45
46end -- class EXAMPLE3