Hey! I'm starting my introductory C++ course exercise work, and I'm in a bit of a trouble trying to figure out the class structure.
The idea of the program is to find out the quickest way possible from a bus stop to the destination bus stop. There's six bus lines - A, B, C, D, E and F - with four stops in each line (A1, A2, etc.), plus a center stop, something like this:
A1-A2-A3-A4--CENTRALSTOP--B4-B3-B2-B1
The busses can driver these lines in three different ways:
- a bus starts from the end of a line and goes to the end of another line via the central stop (A1 -> A2 -> A3 -> A4 -> CentralStop -> F1 ... -> F4)
- a bus starts from the end of a line and goes to the central stop (A1 -> ... -> A4 -> CentralStop)
- a bus starts from the centralstop and goes to the end of a line (CentralStop -> D4 -> ... -> D1)
I figured out that I should start with a class "BusLine", which consists of "BusStop" objects. Then there would be a class called "Bus", which includes the route information, schedules etc. The only problem I've come up with this kind of a class structure is that I can't really think a way to handle the central stop. It isn't really a member of any busline, although it is "a kind of a member" of every line.
Am I totally lost with this kind of structure or is this a (at least somewhat) valid start? :)