The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science

CSci 131 - Data Structures - Fall 1997
Programming Project #2

Due Date: Section 10: Sept. 30, 1997, Section 11: Sept. 29, 1997

The second programming project involves transforming project one so that it uses a predefined keyed table to store the employee information, instead of the array of records that you used in project one. This transformation requires the following steps:

1. Write an employee package. Complete the following package specification and write the corresponding package body.

WITH Currency, Dates;
PACKAGE Our_Employees IS
  TYPE Employee_Record IS PRIVATE;
  FUNCTION Make_Employee(Name: String; ID: Integer;
    Start_Date: Dates.Date; Salary: Currency.Quantity)
    RETURN Employee_Record;
  FUNCTION Retrieve_ID(Employee: Employee_Record) 
    RETURN Integer;
  -- Include one retrieve function for each field
PRIVATE
  TYPE Employee_Record IS RECORD
    Name: String(1..15);
    ID: Integer;
    Start_Date: Dates.Date;
    Salary: Currency.Quantity;
  END RECORD;
END Our_Employees;

2. Write a package Our_Employees.IO, both specification and body, that contains interactive and file-oriented Get and Put procedures.

3. Modify the Tables package in the textbook, program 3.11 (specification) and program 3.14 (body) so that it contains the following subtype declarations:

SUBTYPE Element_Type IS Our_Employees.Employee_Record;
SUBTYPE Key_Type IS Our_Employees.ID;

Complete any unfinished parts of the package body.

4. Modify the main procedure of your first project so that it calls the Insert function as it reads in the records from the file. You should assign sequential IDs to the employees as you insert them into the table. The main procedure should produce the same report as it did in project one, but it should use the Retrieve procedure to access the employee in the database.

5. Now that you've done a batch program to work with the table, do an interactive one. Start with Employee_UI and complete the missing operations in it.

Incorporate all necessary packages, such as Debugging_Support, Dates, Dates.IO, Currency and Currency.IO.