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 29, 1999 (the university make-up day for the snow day)
THIS IS A FINAL DEADLINE - NO LATE PROJECTS CAN BE ACCEPTED!

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 instead of a string.

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. You'll need to make some small changes to the other table operations, to cjeck the value of the Iterating flag.
  • 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);
    PROCEDURE StopTraversal (T: IN OUT TableType);
  END Tables_Generic.Iteration;
(D) 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