I want to simulate dice roll functionality. However, I don't get what I expect. I want to get a Dice with value ranging from 1 to 6 inclusively (dice).
I tried to find it in Eiffel Documentation, but it is very hard to do.
The following code prints values for 10 consecutive rolls:
local
r: RANDOM
do
across
1 |..| 10 as i
from
create r.set_seed (...) -- ... is the initial "seed"
r.start
loop
io.put_integer (r.item \\ 6 + 1)
io.put_new_line
r.forth
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.