Beispiel #1
0
        public void AddCar(TaxiCar car)
        {
            if (countCars >= capacity)
            {
                cars = Expansion();
            }

            cars[countCars++] = car;
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            if (obj.GetType() != this.GetType())
            {
                return(false);
            }

            TaxiCar car = (TaxiCar)obj;

            return(this.company == car.company);
        }
Beispiel #3
0
        private TaxiCar[] Expansion()
        {
            capacity *= 2;
            TaxiCar[] newCars = new TaxiCar[capacity];

            for (int index = 0; index < countCars; index++)
            {
                newCars[index] = cars[index];
            }

            return(newCars);
        }
Beispiel #4
0
        public TaxiCar FindCar(string mark, Color color, double engine, double price, double fuelConsumption)
        {
            TaxiCar car = new TaxiCar();

            for (int index = 0; index < countCars; index++)
            {
                if (cars[index].mark == mark &&
                    cars[index].color == color &&
                    cars[index].engine == engine &&
                    cars[index].price == price &&
                    cars[index].fuelConsumption == fuelConsumption)
                {
                    car = cars[index];
                    break;
                }
            }

            return(car);
        }
Beispiel #5
0
        public static void Use()
        {
            TaxiCar  car1 = new TaxiCar("Almaz", "BMW", Color.Black, 2.9, 1000.6, 12, 2567000);
            TaxiCar  car2 = new TaxiCar("Almaz", "Mercedes-benz", Color.White, 3.2, 1200, 8, 5567000);
            TaxiCar  car3 = new TaxiCar("Almaz", "Nissan", Color.Yellow, 1.2, 450, 9, 7677000);
            Taxipark cc1  = new Taxipark("Almaz", "Almaz");

            cc1.AddCar(car1);
            cc1.AddCar(car2);
            cc1.AddCar(car3);
            cc1.AddCar(car1);
            cc1.AddCar(car2);
            cc1.AddCar(car3);
            cc1.AddCar(car1);
            cc1.AddCar(car2);
            cc1.AddCar(car3);
            cc1.AddCar(car1);
            cc1.AddCar(car2);
            cc1.AddCar(car3);

            cc1.SortCarsByFuel();

            Console.WriteLine(cc1.FindCar("BMW", Color.Black, 2.9, 1000.6, 12));
        }