Exercise #2: Data representation

Here's the Pascal definition of an enumerated type:

type
  MajorArcana = (Juggler, HighPriestess, Empress, Emperor, Pope, Lovers,
                 Chariot, Justice, Hermit, WheelOfFortune, Strength,
                 HangedMan, Death, Temperance, Devil, StruckTower,
                 Stars, Moon, Sun, Judgement, FoolishMan, Universe);
The assignment is to design, write, and test three standard Pascal procedures relating to this data type:

Here are the headers for these three procedures:

procedure ReadMajorArcanum (var Source: Text; var Legend: MajorArcana;
  var Success: Boolean);

procedure WriteMajorArcanum (var Target: Text; Scribend: MajorArcana);

procedure WriteAsBits (var Target: Text; Scribend: MajorArcana);
You may choose whatever string representations you like for the values of this type, provided that distinct values have distinct representations. You may decide for yourself which case to use in the string output and whether the ReadMajorArcanum procedure should be case-sensitive. Document your decisions.

To test the procedures, write a program that invokes them with various arguments and inputs. Before running your program, predict exactly how the program should behave and what output it should produce. Then run the program and examine its behavior and output to confirm or disconfirm your predications.

Submit a listing of your test program, a listing of any input files that it reads from, a run of the test program, and a listing of any output files that the test program creates. You can place all of these things in a log file and send it to me by e-mail.

This program will be due on Friday, September 13.


created September 5, 1996
last revised September 9, 1996