aboutsummaryrefslogtreecommitdiff
path: root/challenge-194/deadmarshal/modula-3/ch1/src/Ch1.m3
blob: d4b0cf9241fae5bab0bf94806b31c0c94ad469ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
MODULE Ch1 EXPORTS Main;

IMPORT IO;
FROM Scan IMPORT Int;
FROM Text IMPORT GetChar,FromChar;

PROCEDURE DigitalClock(T:TEXT):CARDINAL =
  BEGIN
    IF GetChar(T,0) = '?' THEN
      IF Int(FromChar(GetChar(T,1))) < 4 THEN RETURN 2 ELSE RETURN 1 END;
    ELSIF GetChar(T,1) = '?' THEN
      IF Int(FromChar(GetChar(T,0))) < 2 THEN RETURN 9 ELSE RETURN 3 END;
    ELSIF GetChar(T,3) = '?' THEN
      RETURN 5
    ELSE
      RETURN 9
    END;
  END DigitalClock;
  
BEGIN
  IO.PutInt(DigitalClock("?5:00")); IO.Put("\n");
  IO.PutInt(DigitalClock("?3:00")); IO.Put("\n");
  IO.PutInt(DigitalClock("1?:00")); IO.Put("\n");
  IO.PutInt(DigitalClock("2?:00")); IO.Put("\n");
  IO.PutInt(DigitalClock("12:?5")); IO.Put("\n");
  IO.PutInt(DigitalClock("12:5?")); IO.Put("\n");
END Ch1.