
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. This procedure will use the procedure from the lab from last week as part of its prompting. The new 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 Get (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;