Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Help with assignment - stacks


  • Please log in to reply
1 reply to this topic

#1 moey187


    CC Lurker

  • Just Joined
  • Pip
  • 6 posts

Posted 12 September 2011 - 01:56 AM

Hey, I just need help with a data structures and algorithms assignment. I've done quite a bit of it and have attatched my solution in this thread. I have also attatched the assignment question sheet. I would just like someone to let me know if there are any mistakes or improvements needed.


Attached Files

  • 0

#2 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 13 September 2011 - 04:43 AM

General observations on opening the project:
1) ProgramFunctions.h doesn't have header guards.
2) it seems odd that you're using structs instead of classes, especially since some of your structs have constructors as well.
3) Looking at ProgramFunctions.cpp, I would review a number of those functions to see which ones can be included in various classes. For example, assignRandomCarriageID seems like it should be a private method of Train.
4) Train.getTrain: returning a reference to a private member makes the private member NOT private. Identify the functions that need it and make them methods of Train.
5) Carriage: it seems weird that you don't have an overloaded constructor that allows you to set the CarriageID as part of the constructor.
6) You have a few functions that seem really questionable. What is the purpose of printHowManyCarriages? It is only called in one place, contains only one line of code, and obfuscates what's happening in getCarriageCount. It looks like it's a function created for the sake of having a function.

I don't think there's anything inherently bad in what you've done, and it looks like it will probably work (I haven't tested it). It does look like it could be cleaned up a lot, though.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download