Ejemplo n.º 1
0
        public void TestEvictAnimal()
        {
            var aviary = new GlassAviary(GlassAviaryType.WithWater);

            //Успешная попытка выселить существующее животное
            var animal1 = new Amphibian(AmphibianDetachment.Urodela, "семейство1", "род1", "вид1");

            aviary.SettleAnimal(animal1);
            aviary.EvictAnimal(animal1);
            Assert.AreEqual(0, aviary.GetListOfInhabitants().Count);

            //Неуспешная попытка выселить несуществующее животное
            try
            {
                aviary.EvictAnimal(null);
                Assert.Fail();
            }
            catch (ArgumentException) { }

            //Неуспешная попытка выселить отсутствующее в вольере животное
            try
            {
                aviary.EvictAnimal(animal1);
                Assert.Fail();
            }
            catch (ArgumentException) { }
        }
        static void AddByIndex(ArrayList nameList)              //добавление элемента по указанному индексу
        {
            Console.WriteLine("Введите имя обьекта...");
            string objectName = Console.ReadLine();

            Console.WriteLine("Введите массу обьекта...");
            double objectWeieght = double.Parse(Console.ReadLine());

            Console.WriteLine("Выберите тип создаваемого обьекта...");
            Console.WriteLine("*1 - самолет                       *");
            Console.WriteLine("*2 - самолет-амфибия               *");
            int choice1 = int.Parse(Console.ReadLine());

            Console.WriteLine("Введите индекс добавляемого элемента...");
            int objectIndex = int.Parse(Console.ReadLine());    //запрос на ввод индекса добавляемого обьекта

            if (choice1 == 1)
            {
                Aircraft userObject = new Aircraft(objectName, objectWeieght);
                nameList.Insert(objectIndex, userObject);
                Console.WriteLine("Самолет с именем -{0}- и массой -{1}- тонн ------- успешно добавлен в коллецию", objectName, objectWeieght);
            }
            else if (choice1 == 2)
            {
                Amphibian userObject = new Amphibian(objectName, objectWeieght);
                nameList.Insert(objectIndex, userObject);
                Console.WriteLine("Самолет-амфибия с именем -{0}- и массой -{1}- тонн ------- успешно добавлен в коллецию", objectName, objectWeieght);
            }
            else
            {
                Console.WriteLine("Выбран не верный тип создаваемого обьекта");
            }
        }
        static void AddObject(ArrayList nameList)               //добавление элемента (конструктор с двумя параметрами)
        {
            Console.WriteLine("Введите имя обьекта...");
            string objectName = Console.ReadLine();

            Console.WriteLine("Введите массу обьекта...");
            double objectWeieght = double.Parse(Console.ReadLine());

            Console.WriteLine("Выберите тип создаваемого обьекта...");
            Console.WriteLine("*1 - самолет                       *");
            Console.WriteLine("*2 - самолет-амфибия               *");
            int choice1 = int.Parse(Console.ReadLine());

            if (choice1 == 1)
            {
                Aircraft userObject = new Aircraft(objectName, objectWeieght);
                nameList.Add(userObject);
                Console.WriteLine("Самолет с именем -{0}- и массой -{1}- тонн ------- успешно добавлен в коллецию", objectName, objectWeieght);
            }
            else if (choice1 == 2)
            {
                Amphibian userObject = new Amphibian(objectName, objectWeieght);
                nameList.Add(userObject);
                Console.WriteLine("Самолет-амфибия с именем -{0}- и массой -{1}- тонн ------- успешно добавлен в коллецию", objectName, objectWeieght);
            }
            else
            {
                Console.WriteLine("Выбран не верный тип создаваемого обьекта");
            }
        }
Ejemplo n.º 4
0
        private static void TestVehicleAmphibian()
        {
            Motor     motor     = new Motor(FuelType.Oil, 350);
            Amphibian amphibian = new Amphibian(2, 6, motor);

            amphibian.Start();
            Console.WriteLine(amphibian.ToString());

            amphibian.IncreaseSpeed(20);
            amphibian.IncreaseSpeed(10);
            amphibian.IncreaseSpeed(30);
            Console.WriteLine(amphibian.ToString());

            amphibian.GetIntoWater();
            Console.WriteLine(amphibian.ToString());

            amphibian.DecreaseSpeed(15);
            Console.WriteLine(amphibian.ToString());

            amphibian.GetOntoGround();
            Console.WriteLine(amphibian.ToString());

            amphibian.Stop();
            Console.WriteLine(amphibian.ToString());
        }
Ejemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Amphibian amphibian = db.Amphibians.Find(id);

            db.Amphibians.Remove(amphibian);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public void TestGetFullNotation()
        {
            var animal = new Amphibian(AmphibianDetachment.Anura, "Жабы", "Жабы", "Обыкновенная жаба");

            //Проверка корректности формирования полного наименования животного
            var result = animal.GetFullNotation();

            Assert.AreEqual("Amphibian*Anura*Жабы*Жабы*Обыкновенная жаба", result);
        }
        static void AddByIndex()                                    // добавление элемента по индексу
        {
            Vehicle newCraft          = null;
            string  objectName        = null;
            int     continueCondition = 1;
            double  objectWeight      = 0;
            int     craftIndex        = 0;

            do
            {
                Console.WriteLine("Введите индекс добавляемого обьекта...");
                craftIndex = int.Parse(Console.ReadLine());
                if (IndexCheck(craftIndex))
                {
                    Console.WriteLine("Не верный индекс!");
                    continueCondition = 0;
                }
                else
                {
                    Console.WriteLine("Введите имя обьекта...");
                    objectName = Console.ReadLine();
                    if (SearchSame(objectName))
                    {
                        Console.WriteLine("Выбранное вами имя уже существует!");
                        continueCondition = 0;
                    }
                    else
                    {
                        continueCondition = 1;
                    }
                }
            }while (continueCondition == 0);
            if (continueCondition == 1)
            {
                Console.WriteLine("Введите массу обьекта...");
                objectWeight = double.Parse(Console.ReadLine());
                Console.WriteLine("Выберите тип создаваемого обьекта...");
                Console.WriteLine("*1 - самолет                       *");
                Console.WriteLine("*2 - самолет-амфибия               *");
                int typeChoice = int.Parse(Console.ReadLine());
                if (typeChoice == aircraftType)
                {
                    newCraft = new Aircraft(objectName, objectWeight);
                }
                else if (typeChoice == amphibianType)
                {
                    newCraft = new Amphibian(objectName, objectWeight);
                }
                else
                {
                    throw new Exception("Выбран не верный тип создаваемого обьекта");
                }
                vehicleCollection.Insert(craftIndex, newCraft);
            }
        }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "AmphibiansID,AmphibiansName,AmphibiansType,animalSpecies_animalID,DietryType,PopulationNumber")] Amphibian amphibian)
 {
     if (ModelState.IsValid)
     {
         db.Entry(amphibian).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.animalSpecies_animalID = new SelectList(db.animals, "animalID", "animalID", amphibian.animalSpecies_animalID);
     return(View(amphibian));
 }
Ejemplo n.º 9
0
        public void TestToString()
        {
            //Корректное формирование информационной строки
            var animal = new Amphibian(AmphibianDetachment.Anura, "Жабы", "Жабы", "Обыкновенная жаба");
            var str    = "Id:" + animal.Id + "\n" +
                         "Класс:Amphibian\n" +
                         "Отряд:Anura\n" +
                         "Семейство:Жабы\n" +
                         "Род:Жабы, Вид:Обыкновенная жаба";

            Assert.AreEqual(str, animal.ToString());
        }
Ejemplo n.º 10
0
        // GET: Amphibians/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Amphibian amphibian = db.Amphibians.Find(id);

            if (amphibian == null)
            {
                return(HttpNotFound());
            }
            return(View(amphibian));
        }
Ejemplo n.º 11
0
        // GET: Amphibians/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Amphibian amphibian = db.Amphibians.Find(id);

            if (amphibian == null)
            {
                return(HttpNotFound());
            }
            ViewBag.animalSpecies_animalID = new SelectList(db.animals, "animalID", "animalID", amphibian.animalSpecies_animalID);
            return(View(amphibian));
        }
Ejemplo n.º 12
0
 public Animal ToAnimal(AnimalDTO animalDTO)
 {
     try
     {
         if (animalDTO == null || !(animalDTO is AmphibianDTO))
         {
             throw new ArgumentException("Пустой DTO объект (животное) или не подходящего типа!!!");
         }
         var animal = new Amphibian((animalDTO as AmphibianDTO).Detachment,
                                    animalDTO.Family, animalDTO.Genus,
                                    animalDTO.Species);
         return(animal);
     }
     catch (ArgumentException)
     {
         throw;
     }
 }
        static void AddNewObject()               // добавление элемента (конструктор с двумя параметрами)
        {
            Vehicle newCraft          = null;
            string  objectName        = null;
            int     continueCondition = 1;
            double  objectWeight      = 0;

            do
            {
                Console.WriteLine("Введите имя обьекта...");
                objectName = Console.ReadLine();
                if (SearchSame(objectName))
                {
                    Console.WriteLine("Выбранное вами имя уже существует!");
                    continueCondition = 0;
                }
                else
                {
                    continueCondition = 1;
                }
            }while (continueCondition == 0);
            if (continueCondition == 1)
            {
                Console.WriteLine("Введите массу обьекта...");
                objectWeight = double.Parse(Console.ReadLine());
                Console.WriteLine("Выберите тип создаваемого обьекта...");
                Console.WriteLine("*1 - самолет                       *");
                Console.WriteLine("*2 - самолет-амфибия               *");
                int typeChoice = int.Parse(Console.ReadLine());
                if (typeChoice == aircraftType)
                {
                    newCraft = new Aircraft(objectName, objectWeight);
                }
                else if (typeChoice == amphibianType)
                {
                    newCraft = new Amphibian(objectName, objectWeight);
                }
                else
                {
                    throw new Exception("Выбран не верный тип создаваемого обьекта");
                }
                vehicleCollection.Add(newCraft);
            }
        }
        public void WagonFactory_3Ominvore()
        {
            //Assign
            List <Animal> animals     = new List <Animal>();
            Bird          bird_1      = new Bird("test", 10f, AnimalDiet.Ominvores);
            Bird          bird_2      = new Bird("test", 10f, AnimalDiet.Ominvores);
            Amphibian     Amphibian_1 = new Amphibian("test", 10f, AnimalDiet.Ominvores);

            //Act

            animals.Add(bird_1);
            animals.Add(bird_1);
            animals.Add(Amphibian_1);

            var wagons = WagonFactory.GenerateFilledWagons(animals);

            //Assert
            Assert.IsTrue(wagons.Count == 1);
        }
Ejemplo n.º 15
0
        private static void TestAmphibian()
        {
            OilMotor  motor     = new OilMotor(650);
            Amphibian amphibian = new Amphibian(500, 4, motor);

            Console.WriteLine("Amphibian:");
            amphibian.Start();
            amphibian.Accelerate(30);
            Console.WriteLine(amphibian.ToString());

            amphibian.GetIntoWater();
            amphibian.Accelerate(10);
            Console.WriteLine(amphibian.ToString());

            amphibian.Decelerate(5);
            amphibian.GetOntoGround();
            Console.WriteLine(amphibian.ToString());

            amphibian.Stop();
        }
Ejemplo n.º 16
0
        public void TestIsCorrectForSettlement()
        {
            var aviary = new GlassAviary(GlassAviaryType.WithoutWater);

            //Успешная проверка на допустимость заселения животного в подходящий пустой вольер
            var animal1 = new Mammal(MammalDetachment.Rodentia, "семейство1", "род1", "вид1");
            var animal2 = new Mammal(MammalDetachment.Chiroptera, "семейство2", "род2", "вид2");
            var animal3 = new Amphibian(AmphibianDetachment.Anura, "семейство3", "род3", "вид3");
            var animal4 = new Reptile(ReptileDetachment.Testudinata, "семейство4", "род4", "вид4");

            Assert.AreEqual(true, aviary.IsCorrectForSettlement(animal1));
            Assert.AreEqual(true, aviary.IsCorrectForSettlement(animal2));
            Assert.AreEqual(true, aviary.IsCorrectForSettlement(animal3));
            Assert.AreEqual(true, aviary.IsCorrectForSettlement(animal4));

            //Успешная проверка на допустимость заселения животного в подходящий непустой вольер
            aviary.SettleAnimal(animal1);
            var animal5 = new Mammal(MammalDetachment.Rodentia, "семейство1", "род1", "вид2");

            Assert.AreEqual(true, aviary.IsCorrectForSettlement(animal5));

            //Неуспешная проверка на допустимость заселения животного в неподходящий пустой вольер
            aviary.EvictAnimal(animal1);
            var animal6 = new Fish(FishDetachment.Rajiformes, "семейство8", "род8", "вид8");

            Assert.AreEqual(false, aviary.IsCorrectForSettlement(animal6));

            //Неуспешная проверка на допустимость заселения животного в подходящий по типу вольер, но занятый несовместимым животным
            aviary.SettleAnimal(animal1);
            Assert.AreEqual(false, aviary.IsCorrectForSettlement(animal4));

            //Неуспешная проверка на допустимость заселения несуществующего животного
            try
            {
                aviary.IsCorrectForSettlement(null);
                Assert.Fail();
            }
            catch (ArgumentException) { }
        }
        public void WagonFactory_2Ominvore1Carnivore()
        {
            //Assign
            List <Animal> animals     = new List <Animal>();
            Bird          bird_1      = new Bird("bird_1", 2f, AnimalDiet.Ominvores);
            Bird          bird_2      = new Bird("bird_2", 3f, AnimalDiet.Ominvores);
            Amphibian     Amphibian_1 = new Amphibian("Amphibian_1", 2.5f, AnimalDiet.Carnivores);

            //Act

            animals.Add(bird_1);
            animals.Add(bird_1);
            animals.Add(Amphibian_1);

            var wagons = WagonFactory.GenerateFilledWagons(animals);

            //Assert
            Assert.IsTrue(wagons.Count == 2);

            foreach (var wagon in wagons)
            {
                var carnivore = wagon.AllAnimals.Where(x => x.AnimalDiet == AnimalDiet.Carnivores).ToList();
                var ominvore  = wagon.AllAnimals.Where(x => x.AnimalDiet == AnimalDiet.Ominvores).ToList();

                if (carnivore != null && carnivore.Count > 0)
                {
                    Assert.IsTrue(carnivore.Count == 1);

                    for (int i = 0; i < carnivore.Count; i++)
                    {
                        var ominvoresIsSmaller = ominvore.Any(x => x.Weight < carnivore[i].Weight);

                        // if there is a carnivore in the wagon there can't be a smaller ominvore
                        Assert.IsTrue(ominvoresIsSmaller == false);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public void TestConstructor()
        {
            var animal = new Amphibian(AmphibianDetachment.Urodela, "Саламандровые", "Малые тритоны", "Обыкновенный тритон");

            //Проверка параметров корректно созданного животного
            Assert.AreNotEqual("", animal.Id);
            Assert.AreEqual(AnimalClass.Amphibian.ToString(), animal.GetType().Name.ToString());
            Assert.AreEqual(AmphibianDetachment.Urodela, animal.Detachment);
            Assert.AreEqual("Саламандровые", animal.Family);
            Assert.AreEqual("Малые тритоны", animal.Genus);
            Assert.AreEqual("Обыкновенный тритон", animal.Species);

            //Попытка создать животное с некорректными параметрами
            try
            {
                var animal2 = new Amphibian(AmphibianDetachment.Anura, "", "", "");
                Assert.Fail();
            }
            catch (ArgumentException) { }

            //Попытка создать животное с некорректными параметрами
            try
            {
                var animal3 = new Amphibian(AmphibianDetachment.Anura, " ", " ", " ");
                Assert.Fail();
            }
            catch (ArgumentException) { }

            //Попытка создать животное с некорректными параметрами
            try
            {
                var animal4 = new Amphibian(AmphibianDetachment.Anura, "dfd", " ", "");
                Assert.Fail();
            }
            catch (ArgumentException) { }
        }
Ejemplo n.º 19
0
        public static Animal GenerateAnimal(string AnimalType, string[] animalNames, int maxWeight, Random random, float weightScale = 1)
        {
            Animal     animal           = null;
            Array      values           = Enum.GetValues(typeof(AnimalDiet));
            AnimalDiet randomAnimalDiet = (AnimalDiet)values.GetValue(random.Next(values.Length));

            int    index      = random.Next(0, animalNames.Length);
            string animalname = animalNames[index];

            if (AnimalType == typeof(Amphibian).Name)
            {
                animal = new Amphibian(animalname, random.Next(1, maxWeight) * weightScale, randomAnimalDiet);
            }
            if (AnimalType == typeof(Reptile).Name)
            {
                animal = new Reptile(animalname, random.Next(1, maxWeight) * weightScale, randomAnimalDiet);
            }
            if (AnimalType == typeof(Mammal).Name)
            {
                animal = new Mammal(animalname, random.Next(1, maxWeight) * weightScale, randomAnimalDiet);
            }
            if (AnimalType == typeof(Fish).Name)
            {
                animal = new Fish(animalname, random.Next(1, maxWeight) * weightScale, randomAnimalDiet);
            }
            if (AnimalType == typeof(Insect).Name)
            {
                animal = new Insect(animalname, random.Next(1, maxWeight) * weightScale, randomAnimalDiet);
            }
            if (AnimalType == typeof(Bird).Name)
            {
                animal = new Bird(animalname, random.Next(1, maxWeight) * weightScale, randomAnimalDiet);
            }

            return(animal);
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            var myTank      = new Tank(68000, 70);
            var myWarship   = new Warship(35000, 80);
            var myAmphibian = new Amphibian(23000, 40);

            Console.WriteLine("Greetings!\nI see you're in need of " +
                              "troop transport!\n");
            do
            {
                Console.WriteLine("Please enter the number of soldiers you need " +
                                  "to transport:");

                var peopleToTransport = 0;
                while (!int.TryParse(Console.ReadLine(), out peopleToTransport))
                {
                    Console.WriteLine("That is not a valid input, please try again:");
                }

                Console.WriteLine("Enter the distance the TANK " +
                                  "needs to overcome in kilometers:");

                var distanceTank = 0;
                while (!int.TryParse(Console.ReadLine(), out distanceTank))
                {
                    Console.WriteLine("That is not a valid input, please try again:");
                }

                Console.WriteLine("Enter the distance the WARSHIP " +
                                  "needs to overcome in kilometers:");

                var distanceWarship = 0;
                while (!int.TryParse(Console.ReadLine(), out distanceWarship))
                {
                    Console.WriteLine("That is not a valid input, please try again:");
                }


                var distanceAmphibianByLand = 0;
                var distanceAmphibianBySea  = 0;

                while (true)
                {
                    Console.WriteLine("Enter the distance the AMPHIBIAN " +
                                      "needs to overcome by SEA in kilometers:");

                    while (!int.TryParse(Console.ReadLine(), out distanceAmphibianBySea))
                    {
                        Console.WriteLine("That is not a valid input, please try again:");
                    }

                    Console.WriteLine("Enter the distance the AMPHIBIAN " +
                                      "needs to overcome by LAND in kilometers:");

                    while (!int.TryParse(Console.ReadLine(), out distanceAmphibianByLand))
                    {
                        Console.WriteLine("That is not a valid input, please try again:");
                    }

                    if (distanceAmphibianBySea + distanceAmphibianByLand > distanceTank ||
                        distanceAmphibianBySea + distanceAmphibianByLand > distanceWarship)
                    {
                        Console.WriteLine("\n\nThe distance the amphibian has to travel MUST be " +
                                          "shorter than the ones the tank and warship have to cross!\n\n");
                    }
                    else
                    {
                        break;
                    }
                }

                var totalDistanceTank      = myTank.Move(distanceTank);
                var totalDistanceWarship   = myWarship.Swim(distanceWarship);
                var totalDistanceAmphibian = myAmphibian.Move(distanceAmphibianByLand) +
                                             myAmphibian.Swim(distanceAmphibianBySea);

                var totalFuelConsumptionTank = myTank.FuelConsumptionTotal
                                                   (totalDistanceTank, peopleToTransport);
                var totalFuelConsumptionWarship = myWarship.FuelConsumptionTotal
                                                      (totalDistanceWarship, peopleToTransport);
                var totalFuelConsumptionAmphibian = myWarship.FuelConsumptionTotal
                                                        (totalDistanceAmphibian, peopleToTransport);

                var bestTransport = Utility.LeastFuelSpent(totalFuelConsumptionTank,
                                                           totalFuelConsumptionWarship, totalFuelConsumptionAmphibian);

                Console.WriteLine($"\nThe best option for transport is: {bestTransport}");

                switch (bestTransport)
                {
                case ("Tank"):
                    Console.WriteLine(myTank.Print(totalDistanceTank, peopleToTransport));
                    break;

                case ("Warship"):
                    Console.WriteLine(myWarship.Print(totalDistanceWarship, peopleToTransport));
                    break;

                case ("Amphibian"):
                    Console.WriteLine(myAmphibian.Print(totalDistanceAmphibian, peopleToTransport));
                    break;
                }

                Console.WriteLine("\nWould you like to make another shipment?");
                Console.WriteLine(" ___________________________");
                Console.WriteLine("|                           |");
                Console.WriteLine("|Press Y            for Yes |");
                Console.WriteLine("|Press anything else for No |");
                Console.WriteLine("|___________________________|");
            }while (Console.ReadKey().Key == ConsoleKey.Y);
        }
        static void Main(string[] args)
        {
            vehicleCollection = new List <Vehicle>();
            Aircraft  craft1 = new Aircraft("MIG-21", 15.6);
            Amphibian craft2 = new Amphibian("Amphibian-1", 30);
            Aircraft  craft3 = new Aircraft("SU-27", 23.2);
            Amphibian craft4 = new Amphibian("Amphibian-2", 33.3);

            vehicleCollection.Add(craft1);
            vehicleCollection.Add(craft2);
            vehicleCollection.Add(craft3);
            vehicleCollection.Add(craft4);
            int choice = defaultUserChoice;

            do
            {
                Console.WriteLine("**************************************");
                Console.WriteLine("*       Главное меню                 *");
                Console.WriteLine("*       выберите действие            *");
                Console.WriteLine("**************************************");
                Console.WriteLine("1 - просмотр коллекции");
                Console.WriteLine("2 - добавление элемента (конструктор с двумя параметрами)");
                Console.WriteLine("3 - добавление элемента по указанному индексу");
                Console.WriteLine("4 - нахождение элемента с начала коллекции");
                Console.WriteLine("5 - нахождение элемента с конца коллекции");
                Console.WriteLine("6 - удаление элемента по индексу");
                Console.WriteLine("7 - удаление элемента по значению");
                Console.WriteLine("8 - реверс коллекции");
                Console.WriteLine("9 - сортировка");
                Console.WriteLine("10 - выполнение методов всех обьектов, поддерживающих Interface2");
                Console.WriteLine("11 - при помощи Parallel.ForEach итерация по коллекции");
                Console.WriteLine("0 -  выход");
                choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    ShowAll();
                    break;

                case 2:
                    AddNewObject();
                    break;

                case 3:
                    AddByIndex();
                    break;

                case 4:
                    FirstElement();
                    break;

                case 5:
                    LastElement();
                    break;

                case 6:
                    DellByIndex();
                    break;

                case 7:
                    DellByValue();
                    break;

                case 8:
                    ReverseCollection();
                    break;

                case 9:
                    SortCollection();
                    break;

                case 10:
                    ISwiminigMethod();
                    break;

                case 11:
                    ParallelLoopResult result = Parallel.ForEach(vehicleCollection, item =>
                    {
                        Console.WriteLine(item.name);
                    });
                    break;

                default: return;
                }
            }while (choice != 0);
        }
Ejemplo n.º 22
0
        private static void Main()
        {
            var exampleTank      = new Tank(25000, 40);
            var exampleWarship   = new Warship(75000, 50);
            var exampleAmphibian = new Amphibian(10000, 30);

            int tankDistance;
            int warshipDistance;
            int amphibianDriveDistance;
            int amphibianSwimDistance;

            do
            {
                Console.WriteLine("Enter the tank's driving distance:");
                tankDistance = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter the warship's swimming distance:");
                warshipDistance = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter the amphibian's driving distance:");
                amphibianDriveDistance = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter the amphibian swimming distance:");
                amphibianSwimDistance = int.Parse(Console.ReadLine());

                if (amphibianDriveDistance + amphibianSwimDistance > tankDistance ||
                    amphibianDriveDistance + amphibianSwimDistance > warshipDistance)
                {
                    Console.WriteLine("Error! Amphibian needs to have the shortest path!");
                }
            } while (amphibianDriveDistance + amphibianSwimDistance > tankDistance ||
                     amphibianDriveDistance + amphibianSwimDistance > warshipDistance);

            Console.WriteLine("Enter the number of soldiers:");
            var numberOfSoldiers = int.Parse(Console.ReadLine());

            tankDistance           = tankDistance * exampleTank.NumberOfDistancesCovered(numberOfSoldiers);
            amphibianDriveDistance = amphibianDriveDistance * exampleTank.NumberOfDistancesCovered(numberOfSoldiers);
            amphibianSwimDistance  = amphibianSwimDistance * exampleTank.NumberOfDistancesCovered(numberOfSoldiers);
            warshipDistance        = warshipDistance * exampleTank.NumberOfDistancesCovered(numberOfSoldiers);

            exampleTank.Move(ref tankDistance);
            exampleAmphibian.Move(ref amphibianDriveDistance);
            exampleAmphibian.Swim(ref amphibianSwimDistance, exampleAmphibian.AverageSpeed);
            var fullAmphibianDistance = amphibianSwimDistance + amphibianDriveDistance;

            exampleWarship.Swim(ref warshipDistance, exampleWarship.AverageSpeed);

            exampleTank.Print(tankDistance);
            exampleAmphibian.Print(fullAmphibianDistance);
            exampleWarship.Print(warshipDistance);

            var tankFuelConsumed      = exampleTank.FuelConsumed(tankDistance);
            var amphibianFuelConsumed = exampleAmphibian.FuelConsumed(fullAmphibianDistance);
            var warshipFuelConsumed   = exampleWarship.FuelConsumed(warshipDistance);

            Console.WriteLine();

            if (tankFuelConsumed < amphibianFuelConsumed && tankFuelConsumed < warshipFuelConsumed)
            {
                Console.WriteLine("The optimal vehicle is the tank.");
            }
            else if (amphibianFuelConsumed < tankFuelConsumed && amphibianFuelConsumed < warshipFuelConsumed)
            {
                Console.WriteLine("The optimal vehicle is the amphibian.");
            }
            else if (warshipFuelConsumed < amphibianFuelConsumed && warshipFuelConsumed < tankFuelConsumed)
            {
                Console.WriteLine("The optimal vehicle is the warship.");
            }
        }