Posted by Charles Hannum Jr on November 27, 2001 at 22:30:28:
In Reply to: Linked List posted by Billy on November 27, 2001 at 21:14:25:
: Will we get points of for not making a linked list to store the cars and the trucks? For instance, storing them in a statically sized array? Do we get points deducted for not using templates?
McQuain has said we can use the stl queue or our own implementation but I don't believe it must be a templated queue necessarily. OTOH, you might as well write it as a template if you're doing your own implementation.
As for how these objects are stored there is no requirement for any of the data structures in this project as best I can tell from the spec (including the queue, it just makes sense to use one for dispatch calls). The only specific requirement is that whatever way we do store trucks must be via base towtruck pointers. The things we are being critiqued on are inheritance and polymorphism, not design of container classes.
Logically, pointers are cheap and I don't see why there should be an objection to using arrays for storing trucks and cars so long as you use dynamic allocation for instantiating the actual objects. By my design, there is no specific storage for my cars but unless I hear differently I was planning to declare a list of 100 towtruck pointers and be done with it. Since the street is limited to 100 addresses by spec (and the HQ at 0) it doesn't make sense to design a simulation with the capability for more than 100 towtrucks.
OTOH, if they do explicitly require the program to handle any number of tow trucks you can always use that queue template to handle it without going to the additional trouble of adding a linked list to the program.
Post a Followup