home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D4.DMS / in.adf / Beispiele / Birthday.mod < prev    next >
Encoding:
Text File  |  1992-10-10  |  1.2 KB  |  51 lines

  1. MODULE Birthday;
  2.  
  3. IMPORT AVL, io;
  4.  
  5. TYPE
  6.   Person = POINTER TO PersonDesc;
  7.   PersonDesc = RECORD (AVL.SNode)
  8.     birthday: ARRAY 20 OF CHAR;
  9.   END;
  10.  
  11. VAR
  12.   root: AVL.SRoot;
  13.   node: AVL.NodePtr;
  14.   new: Person;
  15.   eingabe: ARRAY 20 OF CHAR;
  16.   name: AVL.String;
  17.  
  18. BEGIN
  19.   AVL.SInit(root);
  20.   REPEAT
  21.     io.WriteLn;
  22.     io.WriteString("  N: Neue Person\n");
  23.     io.WriteString("  G: Geburtstag ausgeben\n");
  24.     io.WriteString("  E: Ende\n\n");
  25.     io.WriteString("Eingabe: ");
  26.     io.ReadString(eingabe);
  27.     io.WriteLn;
  28.     IF (eingabe="n") OR (eingabe="g") THEN
  29.       io.WriteString("Name der Person: ");
  30.       io.ReadString(name);
  31.       IF eingabe="n" THEN
  32.         NEW(new); new.name := name;
  33.         io.WriteString("Geburtstag: ");
  34.         io.ReadString(new.birthday);
  35.         IF ~ AVL.Add(root,new) THEN
  36.           io.WriteString("Person existiert bereits!\n");
  37.         END;
  38.       ELSE
  39.         node := AVL.SFind(root,name);
  40.         IF node=NIL THEN
  41.           io.WriteString("Person nicht gefunden!\n");
  42.         ELSE
  43.           io.WriteString("Geburtstag: ");
  44.           io.WriteString(node(Person).birthday);
  45.           io.WriteLn;
  46.         END;
  47.       END;
  48.     END;
  49.   UNTIL eingabe="e";
  50. END Birthday.
  51.