Пример #1
0
        public void Init()
        {
            expectedResponse = new Airport {
                location = new Location {
                    lat = 4.763385, lon = 52.309069
                }
            };
            var content = JsonConvert.SerializeObject(expectedResponse);

            httpClientMock = HttpClientMockHelper.CreateMock(content);
            var inMemorySettings = new
                                   Dictionary <string, string> {
                { "airportsEndpoint", "https://localhost" },
            };

            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddInMemoryCollection(inMemorySettings)
                                           .Build();


            client = new AirportClient(httpClientMock, configuration);
        }
Пример #2
0
        static void Main(string[] args)
        {
            AirportClient client = new AirportClient();

            string   fromCity;
            string   destinationCity;
            string   departureTime;
            string   arrivalTime;
            string   odp;
            TimeSpan dT;
            TimeSpan aT;


            Console.WriteLine("WSZYSTKIE POLACZENIA - W, KONKRETNE POLACZENIE - K");
            odp = Console.ReadLine();

            if (odp.ToLower() == "k")
            {
                Console.WriteLine("Witaj, podaj miasta miedzy ktorymi chcesz znalezc polaczenie, oraz przedzial czasowy w formie HH:mm");
                Console.WriteLine();

                Console.WriteLine("Miasto startowe: ");
                fromCity = Console.ReadLine();
                Console.WriteLine();

                Console.WriteLine("Miasto docelowe: ");
                destinationCity = Console.ReadLine();
                Console.WriteLine();

                Console.WriteLine("Godzina odlotu: ");
                departureTime = Console.ReadLine();
                Console.WriteLine();

                Console.WriteLine("Godzina przylotu na miejsce: ");
                arrivalTime = Console.ReadLine();
                Console.WriteLine();

                dT = TimeSpan.Parse(departureTime);
                aT = TimeSpan.Parse(arrivalTime);

                try
                {
                    Timetable timetable = new Timetable();
                    timetable.AddConnections(client.GetConnections(fromCity, destinationCity, dT, aT));
                    timetable.Show();
                }
                catch (FaultException <ConnectionNotFoundFault> fault)
                {
                    Console.WriteLine(fault.Detail.Message);
                }


                Console.ReadKey();
                client.Close();
            }
            else if (odp.ToLower() == "w")
            {
                Console.WriteLine("Miasto startowe: ");
                fromCity = Console.ReadLine();
                Console.WriteLine();

                Console.WriteLine("Miasto docelowe: ");
                destinationCity = Console.ReadLine();
                Console.WriteLine();


                dT = TimeSpan.Parse("00:00");
                aT = TimeSpan.Parse("23:59");

                try
                {
                    Timetable timetable = new Timetable();
                    timetable.AddConnections(client.GetConnections(fromCity, destinationCity, dT, aT));
                    timetable.Show();
                }
                catch (FaultException <ConnectionNotFoundFault> fault)
                {
                    Console.WriteLine(fault.Detail.Message);
                }


                Console.ReadKey();
                client.Close();
            }
        }
Пример #3
0
        /// <summary>
        /// Fill the aircraft with passenger or a positionnable client (fire,obserber,alert)
        /// </summary>
        /// <param name="aircraft"></param>
        public override void Do(Aircraft aircraft)
        {
            //Valide que le aircraft est de type passager
            if (aircraft.IsPassengerAircraft())
            {
                PassengerAircraft passAircraft = (PassengerAircraft)aircraft;

                //parcours tous les clients de l'aeroport
                for (int i = 0; i < passAircraft.airport.Clients.Count; i++)
                {
                    //verifie que le client est un client de type aeroport
                    if (passAircraft.airport.Clients[i] is AirportClient)
                    {
                        AirportClient airClient = (AirportClient)passAircraft.airport.Clients[i];

                        //Set la destination de l'avion
                        if (passAircraft.CurrentCapacity == 0)
                        {
                            passAircraft.destinationX = airClient.Destination.X;
                            passAircraft.destinationY = airClient.Destination.Y;
                        }

                        //Verifie si la destionation de l'avion est la meme que la destion du client
                        if (passAircraft.destinationX == airClient.Destination.X && passAircraft.destinationY == airClient.Destination.Y)
                        {
                            //Si l'avion est plein, changer l'etat
                            if (passAircraft.MaxCapacity - passAircraft.CurrentCapacity == 0)
                            {
                                ChangeState(passAircraft);
                            }
                            //remplir l'avion
                            else
                            {
                                if (airClient.Amount > (passAircraft.MaxCapacity - passAircraft.CurrentCapacity))
                                {
                                    airClient.Amount             -= (passAircraft.MaxCapacity - passAircraft.CurrentCapacity);
                                    passAircraft.CurrentCapacity += passAircraft.MaxCapacity - passAircraft.CurrentCapacity;
                                }
                                else
                                {
                                    passAircraft.CurrentCapacity += airClient.Amount;
                                    passAircraft.airport.Clients.Remove(passAircraft.airport.Clients[i]);
                                    i--;
                                }
                            }
                        }
                    }
                }
            }
            else
            {   //Si l'avion est de type positionnable
                RescueAircraft rescueAircraft = (RescueAircraft)aircraft;

                //Parcours la liste de client
                for (int i = 0; i < rescueAircraft.airport.Clients.Count; i++)
                {
                    //Verifie que le client est de type positionnable
                    if (rescueAircraft.airport.Clients[i] is PositionableClient)
                    {
                        PositionableClient posClient = (PositionableClient)rescueAircraft.airport.Clients[i];

                        //Si le client est du meme type que l'avion qui peut le prendre en charger,faire decoller l'avion et retirer le client de la liste de client
                        if ((posClient is Fire && rescueAircraft is WaterBomber) || (posClient is Observer && rescueAircraft is ObserverPlane) || (posClient is RescueTeam && rescueAircraft is RescueHelicopter))
                        {
                            rescueAircraft.destinationX = posClient.PosX;
                            rescueAircraft.destinationY = posClient.PosY;
                            rescueAircraft.client       = posClient;
                            ChangeState(rescueAircraft);
                            i = rescueAircraft.airport.Clients.Count;
                        }
                    }
                }
            }
        }