CSC326

Assignment 4

 

This program gives you practice using an abstract data structure that we developed in class.  

 

A small trucking firm acts as a broker between people who want things shipped and independent drivers who own their own trucks. The company receives requests from customers who want goods shipped from city A to city B. When truckers are free, they call the company and give their location. The company looks at its  shipping requests and arranges for the trucker to take a load.

Input

                       

                        In a loop that ends when the user enters QUIT, prompt the user for one of the following three commands:

 

Keyword

Processing

SHIPPER

The program should prompt the user for the shipper's name, the originating city and the number of pounds to be shipped.

 

DRIVER

The program should prompt the user for the driver's name, the current location (city), and the capacity of the truck in pounds.

QUIT

Quit processing shipper and driver requests.

 

                        Shipper and driver names, as well as cities, are strings of up to ten characters, with no embedded blanks. Pound information is integer data.

Output

                        Prompts and responses to user commands must be printed to the screen. In addition, the following information should be written to an output file (for grading purposes) called "Trucks.out".

1)                               Echo print each shipper request.

2)                               For each driver request

a)                   Echo print the driver request.

b)                   Print a shipper that the driver should service.  It must be one whose city is the same as the driver’s city, and whose pounds are within the capacity of the driver’s truck.  If a driver request comes in and there are no shipper requests for a pickup within the designated radius, or the driver's truck does not have the capacity to service the requests that do exist, print a message to the driver to take a day off.

To do this you must iterate through the list to find the first appropriate shipper request.  This is similar to the iteration that we did in class to print a list.  I provided two member functions for ItemType (poundsIs and cityIs), which you might find useful for this part.  If you wish to use other member functions instead (in a more object oriented approach), feel free to change the ItemType files as needed.

(Extra Credit:  Allow the driver to service as many shippers as he can, provided that the combined pounds of the shipments are within the truck capacity.)

 

1)                               After all the shipper and driver requests have been processed, print a list of those shipper requests still not picked up. (This is the printing of a list that we covered in class).

 

       

Data Structures

                        Store the shipper data as a list (sorted or unsorted).  The file http://www.cs.csi.cuny.edu/~zelikovi/csc326/data/UnsortedList.doc holds the code from our book (slightly modified) with header and implementation code for the unsorted list structure.  I also included the ItemType files with the declaration of a structure for this particular problem

Hand in:

           

¨             A description of how you used the sorted/unsorted list that we covered in class, in English (1-2 paragraphs).

¨             Your source code

¨             A listing of the output file and output screen