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

  1.                                        -- Chapter 12 - Program 4
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Record4 is
  6.  
  7.    type MONTH_NAME is (JAN,FEB,MAR,APR,MAY,JUN,JUL,
  8.                                              AUG,SEP,OCT,NOV,DEC);
  9.  
  10.    type DATE is
  11.       record
  12.          Month : MONTH_NAME;
  13.          Day   : INTEGER range 1..31;
  14.          Year  : INTEGER range 1776..2010;
  15.       end record;
  16.  
  17.    type PERSON is
  18.       record
  19.          Name      : STRING(1..15);
  20.          Birth_Day : DATE;
  21.          Age       : INTEGER := 15;
  22.          Sex       : CHARACTER := 'M';
  23.       end record;
  24.  
  25.    Teacher      : PERSON;
  26.    Class_Member : array(1..35) of PERSON;
  27.    Standard     : constant PERSON := ("John Q. Doe    ",
  28.                                       (MAR,27,1955), 33, 'M');
  29.  
  30.    type EMPTY_RECORD is
  31.       record
  32.          null;
  33.       end record;
  34.  
  35. begin
  36.  
  37.    Teacher.Name := "John Q. Doe    ";
  38.    Teacher.Age := 21;
  39.    Teacher.Sex := 'M';
  40.    Teacher.Birth_Day.Month := OCT;
  41.    Teacher.Birth_Day.Day := 18;
  42.    Teacher.Birth_Day.Year := 1938;
  43.  
  44.    for Index in Class_Member'RANGE loop
  45.       Class_Member(Index).Name := "Suzie Lou Q    ";
  46.       Class_Member(Index).Birth_Day.Month := MAY;
  47.       Class_Member(Index).Birth_Day.Day := 23;
  48.       Class_Member(Index).Birth_Day.Year := 1956;
  49.       Class_Member(Index).Sex := 'F';
  50.    end loop;
  51.  
  52.    Class_Member(4).Name := "Little Johhny  ";
  53.    Class_Member(4).Sex := 'M';
  54.    Class_Member(4).Birth_Day.Day := 17;
  55.    Class_Member(7).Age := 14;
  56.    Class_Member(2) := Standard;
  57.    Class_Member(3) := Standard;
  58.  
  59. end Record4;
  60.  
  61.  
  62.  
  63.  
  64. -- Result of execution
  65.  
  66. --   (No output from this program.)
  67.  
  68.