with Auto ; with Gada.Text_IO ; procedure Mission12 is package Txt renames Gada.Text_IO ; type T_Stats is record Moy : Float ; Min : Integer ; Max : Integer ; Urgences : Integer ; end record ; function Acceleration_Stats (Dir_Abs : Float ; Mesures : Integer) return T_Stats is Action : Auto.T_Action ; Count : Integer ; Somme : Integer ; Result : T_Stats ; begin Somme := 0 ; Count := 0 ; Result := (Moy => 0.0, Min => 9999, Max => 0, Urgences => 0) ; for Num in 1..Mesures loop Action := Auto.Action_Courante ; -- Compter les actions d'urgence if Action.Urgence then Result.Urgences := Result.Urgences + 1 ; end if ; -- Uniquement les actions ayant un changement de direction supérieur ou égal au seuil -- et pas de freinage. if abs(Action.Direction) >= Dir_Abs and Action.Freinage = 0 then -- Pour la moyenne Somme := Somme + Action.Accelere ; Count := Count + 1 ; -- Pour le min if Action.Accelere <= Result.Min then Result.Min := Action.Accelere ; end if ; -- Pour le max if Action.Accelere >= Result.Max then Result.Max := Action.Accelere ; end if ; end if ; Auto.Attend_Ms ; end loop ; if Count > 0 then Result.Moy := Float(Somme) / Float(Count) ; end if ; return Result ; end Acceleration_Stats ; Stats : T_Stats ; begin Auto.Fixer_Destination (Long => -0.20, Lat => 41.63) ; Stats := Acceleration_Stats(Dir_Abs => 4.0, Mesures => 22) ; Txt.Put_Line("Acceleration Moyenne : " & Float'Image(Stats.Moy)) ; Txt.Put_Line("Acceleration Min : " & Integer'Image(Stats.Min)) ; Txt.Put_Line("Acceleration Max : " & Integer'Image(Stats.Max)) ; Txt.Put_Line("Actions d'urgence : " & Integer'Image(Stats.Urgences)) ; end Mission12 ;