Musterlösung zu Aufgabe 4 -- Persons.d


DEFINITION MODULE Persons;
FROM StdIO IMPORT FILE;

  CONST 
     NameLength = 30;
     PhoneLength = 15;
  TYPE
     Name = ARRAY[0..NameLength] OF CHAR;     
     Phone = ARRAY [0..PhoneLength] OF CHAR;

     Date = RECORD
              day : CARDINAL[1..31];
              month: CARDINAL[1..12];
              year: CARDINAL[1900..2100];
            END;

     PersDat = RECORD
                 famName: Name;
                 firstName: Name;
                 birthDate: Date;
                 phone: Phone;
               END;


  PROCEDURE nameIsLess(x,y: PersDat): BOOLEAN;
  (* returns TRUE, if x.famName less than y.famName 
   * otherwise FALSE
   *)

  PROCEDURE nameIsEqual(x,y: PersDat):BOOLEAN;
  (* returns TRUE, if x.famName = y.famName
   * otherwise FALSE
   *)

  PROCEDURE isYounger(x,y: PersDat): BOOLEAN;
  (* returns TRUE, if person x is younger than person y
   * otherwise FALSE
   *)
	
  PROCEDURE sameAge(x,y: PersDat): BOOLEAN;
  (* returns TRUE, if persons x and y have the same birthdate 
   * otherwise FALSE
   *)

  PROCEDURE WriteRec(f: FILE; pers: PersDat);
        (* f - open stream for writing 
	 * writes data with one blank as separator 
	 *)
     
  PROCEDURE ReadRec(f:FILE; VAR pers: PersDat):BOOLEAN;
        (* f - open stream for reading !
	 * reads one record assuming whitespace as separator
	 * TRUE, if done, otherwise FALSE
	 *)
END Persons.

Musterlösung zu Aufgabe 4 || Übungen || Vorlesung || SS 97 || SAI

Franz Schweiggert, 13.06.1997