vendredi 11 mai 2018

How to generate float random numbers in Ada?

I have a program with tasks. I want to generate two random numbers,

First: between 0.5 and 3.5

Second: between 4.5 and 6.5

I have to implement it in a protected unit:

with Ada.Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Numerics.Float_Random; 

procedure simulation is
.
.
.
    protected Helper is
            procedure generateFirstRandomNumber;
            procedure generateSecondRandomNumber;
    end Helper;
.
.
.
protected helper is
        procedure generateFirstRandomNumber is
        begin
        ...
        end generateFirstRandomNumber;

        procedure generateSecondRandomNumber is
        begin
        ...
        end generateSecondRandomNumber;

    end Multi_Printer;
.
.
.
begin
.
.
.
end simulation;

I have two entry points where I have to pass those values.

So how can I implement that two random number generators in the protected unit?




Aucun commentaire:

Enregistrer un commentaire