From the course: C# Hands-on Practice with Data-Structures
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
GitHub Codespaces Solution: Train station platform management - C# Tutorial
From the course: C# Hands-on Practice with Data-Structures
GitHub Codespaces Solution: Train station platform management
Let's use data structures to manage trains and tracks for a train platform system. When a train arrives, it should be added to a queue for holding until it's assigned to a track. As more trains arrive, they'll be added to this queue and assigned a track in first-in, first-out order. Let's create our queue. This will hold the trains waiting to be assigned a track. Our platform will have several tracks, so let's manage those with a list. We'll add a few to get us started. To retrieve all the trains and tracks, we can return these data structure references. The next train to be assigned a track will be at the top of our queue. So as long as this queue is not empty, we can take a peek at the top element and return it. Otherwise, we'll return null. When a train arrives, we'll add it to our train queue so it's ready for track assignment. To assign the next train to a track, we'll first need to get the next train that needs assignment. We can use our GetNextTrain method for this. If this…
Contents
-
-
-
-
-
-
(Locked)
How to use a queue in C#3m 40s
-
(Locked)
CoderPad Solution: Generate binary numbers3m 32s
-
(Locked)
Requirements for the customer service ticketing system41s
-
(Locked)
Implement a queue for processing customer requests3m 46s
-
(Locked)
Monitor incoming and pending requests1m 39s
-
(Locked)
GitHub Codespaces Solution: Train station platform management3m 11s
-
(Locked)
-
-
-