示例#1
0
        static void Main(string[] args)
        {
            var tankDistance     = Functions.TankDistanceInput();
            var warshipDistance  = Functions.WarshipDistanceInput();
            var amfibiaDistance  = Functions.AmfibiaDistanceInput();
            var numberOfSoldiers = Functions.NumberOfSoldiersInput();

            if (amfibiaDistance.Item1 + amfibiaDistance.Item2 <= warshipDistance &&
                amfibiaDistance.Item1 + amfibiaDistance.Item2 <= tankDistance)
            {
                var tank    = new Tank(2800, 35);
                var warship = new Warship(21600, 26);
                var amfibia = new Amfibia(2400, 50);

                var tankFuelConsumptionIndex    = Functions.GetTankConsumptionIndex(tankDistance, numberOfSoldiers, tank);
                var warshipFuelConsumptionIndex = Functions.GetWarshipConsumptionIndex(warshipDistance, numberOfSoldiers, warship);
                var amfibiaFuelConsumptionIndex = Functions.GetAmfibiaConsumptionIndex(amfibiaDistance, numberOfSoldiers, amfibia);

                Console.WriteLine($"\nTank:\n{tank.ToString()}\nFuel consumption index: {tankFuelConsumptionIndex}\n\nWarship:\n{warship.ToString()}\n" +
                                  $"Fuel consumption index: {warshipFuelConsumptionIndex}\n\nAmfibia:\n{amfibia.ToString()}\nFuel consumption index: {amfibiaFuelConsumptionIndex}");

                var fuelIndexes = new double[3];
                fuelIndexes[0] = tankFuelConsumptionIndex;
                fuelIndexes[1] = warshipFuelConsumptionIndex;
                fuelIndexes[2] = amfibiaFuelConsumptionIndex;

                var vehicle = Functions.GetMin(fuelIndexes);

                Console.WriteLine($"\nTrebate izabrati {vehicle}!");
            }
            else
            {
                Console.WriteLine("Put amfibije ne moze biti veci od puta tenka ili ratnog broda!");
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter shortest distance for a tank: ");
            var tankDistance = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter shortest distance for a warship: ");
            var warshipDistance = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter straight land distance for amfibia: ");
            var amfibiaLandDistance = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter straight water distance for amfibia: ");
            var amfibiaWaterDistance = int.Parse(Console.ReadLine());

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

            var simulationTank    = new Tank(62000, 30);
            var simulationWarship = new Warship(35000, 100);
            var simulationAmfibia = new Amfibia(29100, 40);

            TripSetup.SetupTank(ref simulationTank, soldierAmount, tankDistance);
            TripSetup.SetupWarship(ref simulationWarship, soldierAmount, warshipDistance);
            TripSetup.SetupAmfibia(ref simulationAmfibia, soldierAmount, amfibiaLandDistance, amfibiaWaterDistance);
            Console.WriteLine(simulationTank.ToString());
            Console.WriteLine(simulationWarship.ToString());
            Console.WriteLine(simulationAmfibia.ToString());

            Console.WriteLine(OptimalVehicle.OptimalVehicleCalculator(simulationTank, simulationWarship, simulationAmfibia));
        }
示例#3
0
        public static double GetWarshipConsumptionIndex(int warshipDistance, int numberOfSoldiers, Warship warship)
        {
            var overallWarshipDistance         = warship.OverallDistance(warshipDistance, numberOfSoldiers);
            var overallWarshipDistanceWithMove = warship.Swim(overallWarshipDistance);
            var warshipFuelConsumptionIndex    = warship.FuelConsumptionIndex(overallWarshipDistanceWithMove);

            return(warshipFuelConsumptionIndex);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Please type distance between starting and final point for each vehicle");
            Console.WriteLine("Tank distance:");
            var tankDistance    = Console.ReadLine();
            var tankDistanceInt = TryParse(tankDistance);

            Console.WriteLine("Warship distance:");
            var warshipDistance    = Console.ReadLine();
            var warshipDistanceInt = TryParse(warshipDistance);

            Console.WriteLine("Amfibia land distance:");
            var amfibiaLandDistance    = Console.ReadLine();
            var amfibiaLandDistanceInt = TryParse(amfibiaLandDistance);

            Console.WriteLine("Amfibia sea distance:");
            var amfibiaSeaDistance    = Console.ReadLine();
            var amfibiaSeaDistanceInt = TryParse(amfibiaSeaDistance);

            while (amfibiaSeaDistanceInt + amfibiaLandDistanceInt >= warshipDistanceInt ||
                   amfibiaSeaDistanceInt + amfibiaLandDistanceInt >= tankDistanceInt)
            {
                Console.WriteLine("Amfibia total distance must be shortest, type again:");
                Console.WriteLine("Amfibia land distance:");
                amfibiaLandDistance    = Console.ReadLine();
                amfibiaLandDistanceInt = TryParse(amfibiaLandDistance);
                Console.WriteLine("Amfibia sea distance:");
                amfibiaSeaDistance    = Console.ReadLine();
                amfibiaSeaDistanceInt = TryParse(amfibiaSeaDistance);
            }
            Console.WriteLine("Our dear general, now please type number of soldiers for transfer");
            var soldiers    = Console.ReadLine();
            var soldiersInt = TryParse(soldiers);
            var tank1       = new Tank();
            var warship1    = new Warship();
            var amfibia1    = new Amfibia();

            tank1.MoveDistance        = tankDistanceInt;
            warship1.SwimDistance     = warshipDistanceInt;
            amfibia1.MoveDistance     = amfibiaLandDistanceInt;
            amfibia1.SwimDistance     = amfibiaSeaDistanceInt;
            tank1.NumberOfSoldiers    = soldiersInt;
            warship1.NumberOfSoldiers = soldiersInt;
            amfibia1.NumberOfSoldiers = soldiersInt;
            Console.WriteLine("Tank: " + "\n" + tank1.ToString());
            Console.WriteLine("Warship: " + "\n" + warship1.ToString());
            Console.WriteLine("Amfibia: " + "\n" + amfibia1.ToString());
            var amfibiaTotalFuel = amfibia1.FuelOnGivenDistance(amfibia1.Move(amfibia1.MoveDistance),
                                                                amfibia1.Swim(amfibia1.SwimDistance), amfibia1.NumberOfRides(amfibia1.NumberOfSoldiers));
            var tankTotalFuel = tank1.FuelOnGivenDistance(tank1.Move(tank1.MoveDistance),
                                                          tank1.NumberOfRides(tank1.NumberOfSoldiers));
            var warshipTotalFuel = warship1.FuelOnGivenDistance(warship1.Swim(warship1.SwimDistance),
                                                                warship1.NumberOfRides(warship1.NumberOfSoldiers));

            if (tankTotalFuel < warshipTotalFuel && tankTotalFuel < amfibiaTotalFuel)
            {
                Console.WriteLine("General, you should use tank, because it is most efficient vehicle");
            }
            else if (warshipTotalFuel < tankTotalFuel && warshipTotalFuel < amfibiaTotalFuel)
            {
                Console.WriteLine("General, you should use warship, because it is most efficient vehicle");
            }
            else
            {
                Console.WriteLine("General, you should use amfibia, because it is most efficient vehicle");
            }
        }