The George Washington University

School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science

CSci 131 -- Data Structures
Project #6

Due Date: April 14, 1998

The purpose of this project is to gain more experience with linked lists, and also to explore active-iteration techniques. You will extend your Project 5 table package, and modify the Vehicles user interface client.

(A) Make a minor modification to Vehicles and Vehicles.IO, such that the vehicle brand is an enumeration type.

TYPE Brands IS (Ford, Toyota, Volvo, Honda, Kia, Yamaha);

Re-test with your Project 5 vehicles user interface.

(B) Add LAVS (list-of-available-space) storage management (Section 9.2) to the linked-list tables package. Modify InitializeTable, Insert and Delete accordingly.

(C) Add active-iterator functionality (Section 9.6) to the linked-list table package.

  • Add two fields--Iterating (a Boolean) and WhichElement (a pointer)--to the TableType declaration. Make no other changes to the tables package!
  • Develop a child package, Tables_Generic.Iteration, with this spec:
  PACKAGE Tables_Generic.Iteration IS
PROCEDURE StartTraversal (T: IN OUT TableType); FUNCTION RetrieveCurrentElement (T: TableType) RETURN Element; FUNCTION MoreElements (T: TableType) RETURN Boolean; PROCEDURE MoveToNextElement (T: IN OUT TableType); END Tables_Generic.Iteration;

(D) Modify the Vehicles user interface (without further modifying Vehicles or Vehicles.IO!).

  • Instead of declaring a single table for all vehicles, declare an array of tables indexed by the vehicle categories (auto, truck, motorcycle in this case).
  • Modify the UI code to accommodate the new data structures, that is, an incoming record is inserted in the proper table, a search is done over all three tables, etc. Do not modify the tables package itself! All part (D) changes can, and must, be in the UI program only.

(E) Add a new capability to the user interface.

  • When this operation is selected by the user, the interface will display a 2-dimensional report showing, for each brand, the number of autos, trucks, and motorcycles for that brand.
  • This operation will create the report by doing an active iteration over each of the three tables to fill in the cells of a 2-dimensional array declared in the UI.
  • Example:
                  Auto          Truck       Motorcycle
                  ------------------------------------
   Ford             1             2              0
   Toyota           2             0              0
   Volvo            0             1              0
   Honda            4             0              3
   Kia              1             0              0
   Yamaha           0             0              4