with Auto ;
with Gada.Text_IO ;
procedure Mission11 is
package Txt renames Gada.Text_IO ;
function Vitesse_Moy(Mesures : Integer) return Float is
Somme : Float := 0.0 ;
begin
for Num in 1..Mesures loop
Somme := Somme + Auto.Vitesse ;
Auto.Attend_Ms ;
end loop ;
return Somme / Float(Mesures) ;
end Vitesse_Moy ;
function Date_Vitesse_Max(Mesures : Integer) return Float is
Date_Max : Float ;
Vit_Max : Float := -1.0 ;
Vit : Float ;
begin
for Num in 1..Mesures loop
Vit := Auto.Vitesse ;
if Vit > Vit_Max then
Date_Max := Auto.Date ;
Vit_Max := Vit ;
end if ;
Auto.Attend_Ms ;
end loop ;
return Date_Max ;
end Date_Vitesse_Max ;
function Vitesse_Min return Float is
Vit_Min : Float := 99999.0 ;
Vit : Float ;
begin
while not Auto.Arrivee loop
Vit := Auto.Vitesse ;
if Vit < Vit_Min then
Vit_Min := Vit ;
end if ;
Auto.Attend_Ms ;
end loop ;
return Vit_Min ;
end Vitesse_Min ;
begin
Auto.Fixer_Destination (Long => -0.82, Lat => 41.22) ;
Txt.Put_Line("Vitesse moyenne : " & Float'Image(Vitesse_Moy(100)) & " km/h") ;
Auto.Fixer_Destination (Long => 0.5, Lat => 40.18) ;
Txt.Put_Line("Vitesse maximale atteinte à la date " & Float'Image(Date_Vitesse_Max(100)) & "s") ;
Auto.Fixer_Destination (Long => 0.2, Lat => 40.37) ;
Txt.Put_Line("Vitesse minimale : " & Float'Image(Vitesse_Min) & "km/h") ;
end Mission11 ;