Hello users,
Iīve just registered!
I am a student and also happen to have computer science. Now we have a task that is to be finished within 2 weeks. Unfortunately, I am pretty new to programming, and this assignment is a bit more complex than the previous ones. My main problem is just understanding how to link things.
The task shortly summed up: We have to a programm a railway. First you have train tracks, which is a line from point A to point B (so 2D-coordinates). Train tracks can only be horizontal or vertical. After having added the first train track, the second should connect to the first at one end and so for every next trail track that you add. You can also connect horizontal and vertical ones.
And secondly, you have lots of different wagons (like 3 categories of wagons, and to every of those categories you have 3 subcategories). There are many methods, which I should be able to program I think, like "add track", "remove track", "add train" (adds wagon to Train), "delete track", "list track", "list wagons" and many more. One must be able to add wagons onto the train tracks (length and coordinates should fit, if not then error message), and to connect the wagons to a train. (Every wagon has its own ID, so some will, some wont connect).
In the end the user should be able to type commands like "add track (2,3) -> (2,6)" (add track <startpoint> -> <endpoint>), and as a result a track would be added (and saved), and so on. The next track would have to start/end at (2,3) or (2,6), be horizontal or vertical, and not cross the first track, or an error message will have to appear.
Finally, the trains even have a direction of travel and will be able to run, and also to collide, after which they would be taken from the tracks, "but not from the train data storage".
Okaaayy. So. How are all These things linked together? How does one link them together? I donīt even know where to begin with. Itīs hard to decide what of these things are classes, where are objects, how the track is saved after itīs been added. Right now, I am even failing to make a class for the train track.
I would very thankful for some help and advice.
Thanks.