home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / record2.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.1 KB  |  54 lines

  1.                                        -- Chapter 12 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Record2 is
  6.  
  7.    type DATE is
  8.       record
  9.          Month : INTEGER range 1..12;
  10.          Day   : INTEGER range 1..31;
  11.          Year  : INTEGER range 1776..2010;
  12.       end record;
  13.  
  14.    type PERSON is
  15.       record
  16.          Name      : STRING(1..15);
  17.          Birth_Day : DATE;
  18.          Age       : INTEGER;
  19.          Sex       : CHARACTER;
  20.       end record;
  21.  
  22.    Self, Mother, Father : PERSON;
  23.  
  24.    My_Birth_Year : INTEGER renames Self.Birth_Day.Year;
  25.  
  26. begin
  27.  
  28.    Self.Name := "John Q. Doe    ";
  29.    Self.Age := 21;
  30.    Self.Sex := 'M';
  31.    Self.Birth_Day.Month := 10;
  32.    Self.Birth_Day.Day := 18;
  33.    Self.Birth_Day.Year := 1938;
  34.    My_Birth_Year := 1938;        -- Identical to previous statement
  35.  
  36.    Mother := Self;
  37.    Father.Birth_Day := Mother.Birth_Day;
  38.    Father.Birth_Day.Month := Self.Birth_Day.Month - 4;
  39.    Mother.Sex := 'F';
  40.  
  41.    if Mother /= Self then
  42.       Put_Line("Mother is not equal to Self.");
  43.    end if;
  44.  
  45. end Record2;
  46.  
  47.  
  48.  
  49.  
  50. -- Result of execution
  51.  
  52. -- Mother is not equal to Self.
  53.  
  54.