Class TransitNetwork

java.lang.Object
id.klacak.bus_navigator.TransitNetwork

public class TransitNetwork extends Object
In-memory collection of the stops and routes in a transit system.
  • Constructor Details

    • TransitNetwork

      public TransitNetwork()
      Creates an empty transit network.
  • Method Details

    • addStop

      public void addStop(Stop newStop)
      Adds a stop to the network.
      Parameters:
      newStop - stop to add
    • addRoute

      public void addRoute(Route newRoute)
      Adds a route to the network.
      Parameters:
      newRoute - route to add
    • findStop

      public Stop findStop(String stopName)
      Finds a stop by name, ignoring case.
      Parameters:
      stopName - name to search for
      Returns:
      the matching stop, or null when no stop matches
    • findRoute

      public Route findRoute(String routeName)
      Finds a route by its short code, ignoring case.
      Parameters:
      routeName - route code to search for
      Returns:
      the matching route, or null when no route matches
    • getStops

      public List<Stop> getStops()
      Gets all stops registered in this network.
      Returns:
      the mutable list of stops
    • getRoutes

      public List<Route> getRoutes()
      Gets all routes registered in this network.
      Returns:
      the mutable list of routes