Пример #1
0
        public static void CountWord()
        {
            //collect data
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("");
            Console.Write("Please enter the word to check for:   ");
            Console.ForegroundColor = ConsoleColor.Green;
            string usersWord = Console.ReadLine();

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.Write("Please enter the sentence to check:   ");
            Console.ForegroundColor = ConsoleColor.Green;

            //manipulate data
            string  usersSentence = Console.ReadLine().ToLower();
            Input   userInputs    = new Input(usersWord, usersSentence);
            Counter newCounter    = new Counter(userInputs);

            newCounter.IgnoreExpressions();
            string[] list = newCounter.GenerateArray();
            newCounter.Counting(list);

            //return data
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine($"Your word {userInputs.Key} is in that sentence {newCounter.Count} times.");

            //loop
            Start();
        }