PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/random/example1.e

http://github.com/tybor/Liberty
Specman e | 43 lines | 37 code | 5 blank | 1 comment | 1 complexity | 4bfa077d1208ae8760cc36742b3f34c0 MD5 | raw file
 1class EXAMPLE1
 2
 3create {ANY}
 4   main
 5
 6feature {}
 7   main
 8      local
 9         count, range, column: INTEGER
10      do
11         io.put_string("Using the MINIMAL_RANDOM_NUMBER_GENERATOR random number generator.%NHow many numbers? ")
12         io.read_integer
13         count := io.last_integer
14         io.put_string("Range ( > 1)     ? ")
15         io.read_integer
16         range := io.last_integer
17         from
18         until
19            count = 0
20         loop
21            random_number_generator.next
22            io.put_integer(random_number_generator.last_integer(range))
23            count := count - 1
24            if column = 6 then
25               io.put_string("%N")
26               column := 0
27            else
28               column := column + 1
29               io.put_string("%T")
30            end
31         end
32
33         io.put_string("%N")
34      end
35
36feature {}
37   random_number_generator: RANDOM_NUMBER_GENERATOR
38         -- Note: this is a once function in order to use always the same RANDOM_NUMBER_GENERATOR.
39      once
40         create {MINIMAL_RANDOM_NUMBER_GENERATOR} Result.make
41      end
42
43end -- class EXAMPLE1