WITH Ada.Text_IO;
WITH Simple_Dates;
PACKAGE Cars IS
------------------------------------------------------------------
--| This package provides data structures and operations for
--| manipulating a simple "data base" of car records, each
--| record containing a tag number, car make, date of purchase
--| and owner's name.
--| The package makes use of resources provided
--| by the package Simple_Dates.
--|
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: November 1996
------------------------------------------------------------------
-- constant and type definitions
NameSize: CONSTANT Positive := 10;
MaxCars: CONSTANT Positive := 25;
SUBTYPE TagType IS Positive RANGE 000001..777777;
SUBTYPE NameType IS String(1..NameSize);
TYPE Makes IS (Ford, Chevrolet, Honda, Subaru);
TYPE Car IS RECORD
TagNumber: TagType;
Make: Makes;
PurchaseDate: Simple_Dates.Date;
Owner: NameType;
END RECORD;
-- operations
PROCEDURE Get (Item: OUT Car);
-- Pre: None
-- Post: Gets a car record, robustly, from the keyboard
PROCEDURE Put (Item: IN Car);
-- Pre: Item is defined
-- Post: Displays one car record on the screen
PROCEDURE DisplayDatabase;
-- Pre: The database has at least been cleared
-- Post: Displays the entire database on the screen
PROCEDURE ClearDatabase;
-- Pre: None
-- Post: The database behaves as though it is empty
PROCEDURE ReadDatabase;
-- Pre: None
-- Post: The database is read in from a disk file
PROCEDURE WriteDatabase;
-- Pre: The database has at least been cleared
-- Post: The database is written out to a disk file
PROCEDURE FindCar(Tag: TagType;
Item: OUT Car; Success: OUT Boolean);
-- Pre: Tag is defined
-- Post: If this car is already in the database, returns the
-- car record and Success is True;
-- otherwise, Success is False
PROCEDURE AddCar (Item: IN Car; Success: OUT Boolean);
-- Pre: Item is defined
-- Post: If this car is not already in the database, adds this
-- car to the database and Success is True;
-- otherwise, Success is False
PROCEDURE DeleteCar (Tag: TagType; Success: OUT Boolean);
-- Pre: Tag is defined
-- Post: If this car is already in the database, deletes this
-- car from the database and Success is True;
-- otherwise, Success is False
END Cars;