Exemple #1
0
        /// <summary>
        /// board passengers
        /// </summary>
        /// <param name="addingAmount">count of peoples in generating queue</param>
        public override List <Passenger.Passenger> BoardPassengers(int addingAmount)
        {
            List <Passenger.Passenger> tmp       = new List <Passenger.Passenger>();
            List <Passenger.Passenger> taxiQueue =
                new TaxiQueue(addingAmount).GeneratePassengers(new TaxiPassengersBuilder());

            foreach (var pretender in BoardTaxi.Instance().BoardPassenger(Passengers.Count, ref taxiQueue))
            {
                if (pretender is Adult)
                {
                    tmp.Add(pretender);
                    continue;
                }

                if (pretender is Child)
                {
                    if (ChildChairsExisting)
                    {
                        tmp.Add(pretender);
                        continue;
                    }
                    else
                    {
                        throw new Exception("Sorry, I have no childchairs");
                    }
                }

                if (pretender is Preferential)
                {
                    throw new Exception("Sorry, we don't transport preferentials");
                }
            }
            Passengers.AddRange(tmp);
            return(taxiQueue);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            List <string> names = new List <string>()
            {
                "John", "Jack", "Liz", "Alan", "Ann",
                "Ire", "Kate", "Mary", "Jane", "Sue", "Bill",
                "Will", "Hugh", "Alex", "Sandro", "Kris",
                "Lothar", "Karl", "Ingrid", "Aaron", "Darina",
                "Bianka", "Dan"
            };

            List <string> surnames = new List <string>()
            {
                "Black", "Brown", "Scot", "Ericsson",
                "Jeferson", "Li", "Martel", "King", "Eir"
            };

            Random rnd = new Random();



            List <Passenger> busQueue = new List <Passenger>();

            for (int i = 0; i < 140; i++)
            {
                busQueue.Add(new BusPassenger(
                                 $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}", $"ticket{i}")
                             );
            }

            List <Driver> busDrivers = new List <Driver>();

            for (int i = 0; i < 8; i++)
            {
                busDrivers.Add(new BusDriver(
                                   $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}")
                               );
            }

            Voyage busVoyage = new Voyage(BoardBus.BoardCarInstance(), busDrivers, busQueue);

            Console.WriteLine(busVoyage);
            Console.WriteLine(BoardBus.BoardCarInstance());



            List <Passenger> taxiQueue = new List <Passenger>();

            for (int i = 0; i < 140; i++)
            {
                taxiQueue.Add(new TaxiPassenger(
                                  $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}", rnd.NextDouble() * 10)
                              );
            }

            List <Driver> taxiDrivers = new List <Driver>();

            for (int i = 0; i < 8; i++)
            {
                taxiDrivers.Add(new TaxiDriver(
                                    $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}")
                                );
            }

            Voyage taxiVoyage = new Voyage(BoardTaxi.BoardCarInstance(), taxiDrivers, taxiQueue);

            Console.WriteLine(taxiVoyage);
            Console.WriteLine(BoardTaxi.BoardCarInstance());



            List <Passenger> queue = new List <Passenger>();

            for (int i = 0; i < 41; i++)
            {
                queue.Add(new BusPassenger(
                              $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}", $"ticket-{i}")
                          );
                queue.Add(new TaxiPassenger(
                              $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}", rnd.NextDouble() * 10)
                          );
            }

            List <Driver> drivers = new List <Driver>();

            for (int i = 0; i < 4; i++)
            {
                drivers.Add(new BusDriver(
                                $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}")
                            );
                drivers.Add(new TaxiDriver(
                                $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}")
                            );
            }

            Voyage voyage1 = new Voyage(BoardBus.BoardCarInstance(), drivers, queue);
            Voyage voyage2 = new Voyage(BoardTaxi.BoardCarInstance(), drivers, queue);

            Console.WriteLine(voyage1);
            Console.WriteLine(voyage2);
            Console.WriteLine(BoardBus.BoardCarInstance());
            Console.WriteLine(BoardTaxi.BoardCarInstance());
        }
Exemple #3
0
 protected override Driver DriverInstance(string name)
 {
     return(Driver ??= BoardTaxi.Instance().BoardDriver(name));
 }
        public static void Main(string[] args)
        {
            List <string> names = new List <string>()
            {
                "John", "Jack", "Liz", "Alan", "Ann",
                "Ire", "Kate", "Mary", "Jane", "Sue", "Bill",
                "Will", "Hugh", "Alex", "Sandro", "Kris",
                "Lothar", "Karl", "Ingrid", "Aaron", "Darina",
                "Bianka", "Dan"
            };

            List <string> surnames = new List <string>()
            {
                "Black", "Brown", "Scot", "Ericsson",
                "Jeferson", "Li", "Martel", "King", "Eir"
            };

            Random rnd = new Random();

            DriverStore driverStore = new DriverStore();

            for (int i = 0; i < 5; i++)
            {
                driverStore.Add(new BusDriver(
                                    $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}")
                                );
                driverStore.Add(new TaxiDriver(
                                    $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}")
                                );
            }

            PassengerStore passengerStore = new PassengerStore();

            for (int i = 0; i < 140; i++)
            {
                passengerStore.Add(new BusPassenger(
                                       $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}", $"ticket-{i}")
                                   );
                passengerStore.Add(new TaxiPassenger(
                                       $"{names[rnd.Next(names.Count)]} {surnames[rnd.Next(surnames.Count)]}", rnd.NextDouble() * 10)
                                   );
            }


            BoardBus Krukovo = new BoardBus();

            while (passengerStore.Count(typeof(BusPassenger)) != 0 &&
                   driverStore.Count(typeof(BusDriver)) != 0)
            {
                int x = Krukovo.BoardDriver(driverStore);
                int y = Krukovo.BoardPassengers(passengerStore, 35);
                Console.WriteLine($"*{x}*{y}*");
                Console.WriteLine(Krukovo.GetCar());
            }

            BoardTaxi Area17 = new BoardTaxi();

            while (passengerStore.Count(typeof(TaxiPassenger)) != 0 &&
                   driverStore.Count(typeof(TaxiDriver)) != 0)
            {
                int x = Area17.BoardDriver(driverStore);
                int y = Area17.BoardPassengers(passengerStore, 6);
                Console.WriteLine($"*{x}*{y}*");
                Console.WriteLine(Area17.GetCar());
            }
        }