public void LaunchAllMissiles()
        {
            int            successfulLaunches = 0;
            List <Missile> launchableMissiles = Launcher.AllMissiles.Where(mis => mis.IsFailed == false).ToList();

            if (launchableMissiles.Count == 0)
            {
                Console.WriteLine("No missiles to launch.");
                return;
            }
            int totalAmount = Launcher.currentAmount;
            int distance    = UserInputValidator.CalculateDistance(1500);

            foreach (var missile in launchableMissiles)
            {
                missile.Launch(distance);
                if (!missile.IsFailed)
                {
                    RemoveMissileFromInventory(missile);
                    successfulLaunches++;
                }
            }
            if (successfulLaunches > 0)
            {
                Console.WriteLine($"{successfulLaunches} missiles were launched!");
                Console.WriteLine($"All other {totalAmount - successfulLaunches} are failed missiles.");
            }
            else
            {
                Console.WriteLine($"all {launchableMissiles.Count} launchable missiles were failed!");
            }
        }
        public void LaunchMissile()
        {
            string type = UserInputValidator.ReadMissileTypeName("Enter missile type to launch:");

            Console.WriteLine("Enter amount of missiles to launch");
            int amount = UserInputValidator.ReadIntParser();

            LaunchissileChecker(type, amount);
        }
        public double CalculateChance()
        {
            int distance = UserInputValidator.CalculateDistance(1500, TargetMissile);

            if (distance == 1)
            {
                Console.WriteLine("Missile has 100 launch success rate");
                return(100);
            }
            return(100 - distance / 1500.0);
        }
Пример #4
0
        public static int CalculateDistance(int maxDistance, string TargetMissile = "war")
        {
            Console.WriteLine($"Please enter the target`s distance for missile {TargetMissile} (1-{maxDistance}):");
            int distance = UserInputValidator.ReadIntParser();

            while (distance > 1500)
            {
                Console.WriteLine($"Distance cannot be above {maxDistance}km. Please try again:");
                distance = UserInputValidator.ReadIntParser();
            }
            return(distance);
        }
Пример #5
0
        public static Missile CreateMissile(LauncherController LaunHandler)
        {
            string type = UserInputValidator.ReadMissileTypeName("Which Type of missile would you like to create?");

            LauncherMenuRunner.ShowTechniquesMenu(LaunHandler.Launcher);
            ITechnique tech = UserInputValidator.GetChoiceOfDictionary <int, ITechnique>(LaunHandler.Launcher.LaunchTechniques);

            while (tech.TargetMissile != type)
            {
                Console.WriteLine($"The technique does not fit to {type} missile, please choose the currect on:");
                tech = UserInputValidator.GetChoiceOfDictionary <int, ITechnique>(LaunHandler.Launcher.LaunchTechniques);
            }
            return(CreateMissile(type, tech));
        }
Пример #6
0
        public static string ReadMissileTypeName(string output)
        {
            //Console.WriteLine(output);
            //Console.WriteLine("[" + String.Join(" / " , Enum.GetNames(typeof(MissileTypes))) + "]");
            int count = 1;
            Dictionary <int, string> missileTypes = new Dictionary <int, string>();

            foreach (string mtype in Enum.GetNames(typeof(MissileTypes)))
            {
                missileTypes.Add(count, mtype);
                count++;
            }
            LauncherMenuRunner.PrintMenuFromDict <int, string>(missileTypes, output);
            return(UserInputValidator.GetChoiceOfDictionary <int, string>(missileTypes));
        }
        public void RemoveMissile()
        {
            ShowReport();
            Console.WriteLine();
            Console.WriteLine("Enter the index of the missile which you would like to remove");
            int choice = UserInputValidator.ReadIntParser();

            try
            {
                Missile m = Launcher.AllMissiles[choice];
                RemoveMissileFromInventory(m);
            }
            catch
            {
                Console.WriteLine("No missile for this index");
            }
        }