Example #1
0
        public IList <IAirConnection> GetIndirectAirConnections(string portA, string portB)
        {
            IList <IAirConnection> list1 = new List <IAirConnection>();
            IList <IAirConnection> list2 = new List <IAirConnection>();

            foreach (var conn in AirConnections)
            {
                if (conn.AirportA.Equals(portA))
                {
                    list1.Add(conn);
                }
                if (conn.AirportB.Equals(portB))
                {
                    list2.Add(conn);
                }
            }
            IList <IAirConnection> list3 = new List <IAirConnection>();

            foreach (AirConnection conn in list1)
            {
                foreach (AirConnection conn2 in list2)
                {
                    if (conn.AirportB.Equals(conn2.AirportA) && conn2.DepartureTime >= conn.ArrivalTime)
                    {
                        AirConnection result = (AirConnection)conn.Clone();
                        result.Connections.Add(conn2);
                        list3.Add(result);
                    }
                }
            }
            return(list3);
        }
        public object Clone()
        {
            AirConnection airConnection = (AirConnection)MemberwiseClone();

            airConnection.Connections = new List <AirConnection>();
            Connections.ToList().ForEach(conn => airConnection.Connections.Add(conn));
            return(airConnection);
        }
Example #3
0
        public IList <IAirConnection> LoadDatabase(String path)
        {
            IList <IAirConnection> airConnections = new List <IAirConnection>();
            var csvRows = File.ReadAllLines(path, Encoding.Default).ToList();

            foreach (var row in csvRows.Skip(1))
            {
                var           columns = row.Split(',');
                AirConnection airData = new AirConnection(columns);
                airConnections.Add(airData);
            }
            return(airConnections);
        }