Yurttas/PL/IL/Ada-95/F/03/02/00/complex 02 p.adb
Jump to navigation
Jump to search
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-- complex_02_p.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20package body Complex_02_P is
21
22 function Assemble(A,
23 B : in Real) return Complex is
24 begin
25 return (A, B);
26 end Assemble;
27
28 function Real_Part(C : in Complex) return Real is
29 begin
30 return (C.R_Part);
31 end Real_Part;
32
33 function Imaginary_Part(C : in Complex) return Real is
34 begin
35 return (C.I_Part);
36 end Imaginary_Part;
37
38 function "+"(C,
39 D : in Complex) return Complex is
40 begin
41 return (C.R_Part+D.R_Part, C.I_Part+D.I_Part);
42 end "+";
43
44 package Real_IO is new Float_IO(Real); use Real_IO;
45
46 procedure Put_Complex(C : in Complex) is
47 begin
48 Put(Real_Part(C));
49 Put(Imaginary_Part(C));
50 New_Line;
51 end Put_Complex;
52
53end Complex_02_P;