
The purpose of this project is to give you some practice working with subtypes, loops, robust input, procedures, and packages.
Everything you need is in Chapters 1-5. A short introduction to procedures will be given in labs.
Develop a new date package, Date_Ops that uses Ada.Calendar features to validate and compare dates. You must also provide an executable procedure(s) which tests this package. The package has the following specification:
WITH Ada.Calendar;
PACKAGE Date_Ops IS------------------------------------------------------------------------
--| Specification for package containing a few common date operations.--| Author: Michael B. Feldman, The George Washington University--| Last Modified: March 2001
------------------------------------------------------------------------
FUNCTION IsValidDate (Month: Ada.Calendar.Month_Number; Day: Ada.Calendar.Day_Number; Year: Ada.Calendar.Year_Number)
RETURN Boolean;
-- Pre: Month, Day, and Year have well-defined values
-- Post: returns True if the three parameters together
-- form a valid date
FUNCTION IsEarlier (Month1: Ada.Calendar.Month_Number; Day1: Ada.Calendar.Day_Number; Year1: Ada.Calendar.Year_Number;
Month2: Ada.Calendar.Month_Number; Day2: Ada.Calendar.Day_Number; Year2: Ada.Calendar.Year_Number)
RETURN Boolean;
-- Pre: All six parameters have well-defined values, and each of the
-- two sets of parameters forms a valid date -- Post: returns True if the date formed by Month1, Day1, Year1 is -- earlier than the date formed by Month2, Day2, Year2, and-- False otherwise
PROCEDURE Get
(Month: OUT Ada.Calendar.Month_Number; Day: OUT Ada.Calendar.Day_Number; Year: OUT Ada.Calendar.Year_Number);
-- Pre: None
-- Post: Prompt user for values and validate them;
-- Month, Day, and Year together form a valid dateEND Date_Ops_2;
Notes:
The Get procedure introduces the idea of robust
input. The user should be able to enter any Integer value. If the value is in
range, the Get procedure continues
by calling IsValidDate to check if the date entered is valid. If any of the values are out of
the range for Ada.Calendar or the
numbers entered do not form a valid date, the user is asked for input again. Note
that this is not a completely robust procedure. It will still raise a Data_Error if a user tries to enter letters of Float
values.
The input format
for the Get procedure is MM DD YYYY. The user should enter the date all at once and should b asked to reenter
a date if any of the values are out of range
IsEarlier assumes that he two dates given form a valid date.
What to submit: See the document Preparation and Grading of Programming Projects for details. Your test plan and associated test program should include a proper set of tests for each of the two functions.