Yurttas/PL/IL/Ada-95/F/04/01/00/shapes p.adb

 1--
 2-- Copyright(C) 1998
 3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4--
 5-- Permission to use, copy, modify, and distribute this
 6-- software and its documentation for EDUCATIONAL purposes
 7-- and without fee is hereby granted provided that this
 8-- copyright notice appears in all copies.
 9--
10 
11-- date   : January 1, 1998.
12-- authorĀ : Salih Yurttas.
13
14-- shapes_p.adb
15
16
17with Ada.Numerics;
18use Ada.Numerics;
19
20with Ada.Numerics.Elementary_Functions;
21use Ada.Numerics.Elementary_Functions;
22
23package body Shapes_P is
24
25  function Area(C : in Circle) return Float is
26  begin
27    return Ada.Numerics.Pi * C.Radius**2;
28  end Area;
29
30-- The area is computed using Heron's formula.
31-- S is half the perimeter.
32
33  function Area(T : in Triangle) return Float is
34    S : constant Float := 0.5 * (T.A + T.B + T.C);
35  begin
36    return Sqrt(S * (S - T.A) * (S - T.B) * (S - T.C));
37  end Area;
38
39end Shapes_P;