.
MODULE D1;
<* NOOPTIMIZE + *>
FROM IO IMPORT RdChar, WrChar, WrStr, RdStr,
WrLn, RdCard, WrCard, RdInt, WrInt, RdReal, WrReal, RdBool, WrBool;
TYPE
ActivityEn = (NO_ACTIVITY, MEETING,
TEACHING, LUNCH, HOLIDAY);
DaysEn = (MONDAY, TUESDAY,
WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY, SUNDAY);
HoursSb = [8..18];
DayAr = ARRAY HoursSb OF ActivityEn;
AgendaAr = ARRAY DaysEn OF DayAr;
PROCEDURE WrActivityEn(activity: ActivityEn);
(* write the activity enum in words *)
BEGIN
CASE activity OF
NO_ACTIVITY
: WrStr("empty");
| MEETING:
WrStr("meeting");
| TEACHING:
WrStr("teaching");
| LUNCH: WrStr("lunch");
| HOLIDAY:
WrStr("holiday");
ELSE WrStr("unknown
activity");
END;
END WrActivityEn;
VAR agenda:
AgendaAr;
(* variable-declarations *)
day: DaysEn;
hour: HoursSb;
BEGIN
WrLn;
(* fill the agenda *)
agenda[MONDAY][9] := MEETING;
agenda[MONDAY][12] := LUNCH;
agenda[MONDAY][13] := TEACHING;
agenda[MONDAY][14] := TEACHING;
agenda[MONDAY][15] := TEACHING;
agenda[MONDAY][16] := TEACHING;
FOR hour := MIN(HoursSb) TO MAX(HoursSb) DO
agenda[TUESDAY][hour] := HOLIDAY;
END;
agenda[WEDNESDAY][8] := MEETING;
agenda[WEDNESDAY][9] := MEETING;
agenda[WEDNESDAY][12] := LUNCH;
agenda[WEDNESDAY][13] := LUNCH;
agenda[WEDNESDAY][14] := TEACHING;
agenda[WEDNESDAY][15] := TEACHING;
agenda[THURSDAY][13] := LUNCH;
agenda[THURSDAY][14] := LUNCH;
agenda[FRIDAY][13] := LUNCH;
(* print the agenda *)
END D1.