Пример #1
0
        public void GetSentece()
        {
            try
            {
                if (isOperation)
                {
                    throw new Exception("Possible only 1 operation");
                }

                if (EnterString != EmptyString)
                {
                    string punctuation   = ".!?";
                    string countSentence = (EnterString.Where(x => punctuation.Contains(x)).Count() + 1).ToString();
                    MessageBox.Show("Number of sentence " + countSentence
                                    );
                }
                else
                {
                    throw new Exception("Nothing to count");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error: " + exp.Message);
            }
        }
Пример #2
0
        public void GetVowelsAndConsonants()
        {
            try
            {
                if (isOperation)
                {
                    throw new Exception("Possible only 1 operation");
                }

                if (EnterString != EmptyString)
                {
                    string vowels          = "уеыаоэяиёюaeiouy";
                    string consonants      = "цкнгшщзхфвпрлджчсмтбbcdfghjklmnpqrstvwxz";
                    string countVowels     = EnterString.Where(x => vowels.Contains(x)).Count().ToString();
                    string countConsonants = EnterString.Where(x => consonants.Contains(x)).Count().ToString();
                    MessageBox.Show("Number of vowels " + countVowels +
                                    "\nNumber of consonants " + countConsonants
                                    );
                }
                else
                {
                    throw new Exception("Nothing to count");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error: " + exp.Message);
            }
        }
Пример #3
0
 public void Replace_Step2(string sub)
 {
     ToReplace   = sub;
     EnterString = EnterString.Replace(WhatReplace, ToReplace);
     isReplace   = false;
     isOperation = false;
     WhatReplace = ToReplace = EmptyString;
 }
Пример #4
0
        public void DelteSubString(string str)
        {
            try
            {
                if (isOperation)
                {
                    throw new Exception("Possible only 1 operation");
                }

                if (EnterString != null && str != "")
                {
                    EnterString = EnterString.Replace(str, "");
                }
                else
                {
                    throw new Exception("Nothing delete");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error: " + exp.Message);
            }
        }