Fhnw.Ecnf.RoutePlanner.RoutePlannerLib.Routes.FindLink C# (CSharp) Method

FindLink() protected method

Finds the link between two cities.
protected FindLink ( City c1, City c2, TransportModes t ) : Link
c1 City first city
c2 City second city
t TransportModes
return Link
        protected Link FindLink(City c1, City c2, TransportModes t)
        {
            foreach (Link l in routes)
            {
                if (t.Equals(l.TransportMode) &&
                          ((c1.Equals(l.FromCity) && c2.Equals(l.ToCity))
                        || (c2.Equals(l.FromCity) && c1.Equals(l.ToCity))))
                {
                    return new Link(c1, c2, l.Distance, TransportModes.Rail);
                }
            }
            return null;
        }