The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 131 -- Algorithms and Data Structures I
Lab #6
For labs meeting Oct. 3 and 5, 2000

This lab involves working with robust input and output.

Modify the package programs51/robust_input so that the calling program can specify the prompt and error messages. Also, add to the robust input package a generic procedure Get that can be instantiated for an enumeration type. The new package spec will look like

PACKAGE Robust_Input IS
------------------------------------------------------------------
--| Package for getting numeric input robustly.
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: February 1999
-----------------------------------------------------------------:

  PROCEDURE Get (Item : OUT Integer;
                 MinVal : IN Integer;
                 MaxVal : IN Integer;
                 Prompt: IN String := "";
                 ErrorMessage: IN String := "");
  -- Gets an integer value in the range MinVal..MaxVal from the terminal
  -- Pre:  MinVal and MaxVal are defined
  -- Post: MinVal <= Item <= MaxVal

  PROCEDURE Get (Item : OUT Float;
                 MinVal : IN Float;
                 MaxVal : IN Float;
                 Prompt: IN String := "";
                 ErrorMessage: IN String := "");
  -- Gets a float value in the range MinVal..MaxVal from the terminal
  -- Pre:  MinVal and MaxVal are defined
  -- Post: MinVal <= Item <= MaxVal

  GENERIC
    TYPE Enum IS (<>);
  PROCEDURE GetEnum (Item : OUT Enum;
                     Prompt: IN String := "";
                     ErrorMessage: IN String := "");
  -- Gets a value in the given enumeration type
  -- Pre:  None
  -- Post: Item is in the given enumeration type

END Robust_Input;