コード例 #1
0
 private void removeSubstrBtn_Click(object sender, EventArgs e)
 {
     try
     {
         outputField.Text = TextCalculator.RemoveSubstr(
             userInput1.Text,
             userInput2.Text == "" ? userInput3.Text : userInput2.Text
             );
     }
     catch (Exception)
     {
         outputField.Text = "Invalid input";
     }
 }
コード例 #2
0
 private void charByIndexBtn_Click(object sender, EventArgs e)
 {
     try
     {
         outputField.Text = TextCalculator.GetCharByIndex(
             userInput1.Text,
             Convert.ToInt32(userInput2.Text)
             )
                            .ToString();
     }
     catch (Exception)
     {
         outputField.Text = "Invalid input";
     }
 }
コード例 #3
0
 private void doubleVowelsBtn_Click(object sender, EventArgs e)
 {
     try
     {
         outputField.Text = userInput1.Text != "" ?
                            TextCalculator.GetDoubledVowels(userInput1.Text) :
                            userInput2.Text != "" ?
                            TextCalculator.GetDoubledVowels(userInput2.Text) :
                            userInput3.Text != "" ?
                            TextCalculator.GetDoubledVowels(userInput3.Text) :
                            throw new Exception();
     }
     catch (Exception)
     {
         outputField.Text = "Enter text first";
     }
 }
コード例 #4
0
 private void stringLengthBtn_Click(object sender, EventArgs e)
 {
     try
     {
         outputField.Text = userInput1.Text != "" ?
                            TextCalculator.GetStringLength(userInput1.Text).ToString() :
                            userInput2.Text != "" ?
                            TextCalculator.GetStringLength(userInput2.Text).ToString() :
                            userInput3.Text != "" ?
                            TextCalculator.GetStringLength(userInput3.Text).ToString() :
                            throw new Exception();
     }
     catch (Exception)
     {
         outputField.Text = "Enter text first";
     }
 }
コード例 #5
0
        private void SubstrToSubstrBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (
                    userInput1.Text == "" ||
                    userInput2.Text == "" ||
                    userInput3.Text == ""
                    )
                {
                    throw new Exception();
                }

                outputField.Text = TextCalculator.SubstrReplace(
                    userInput1.Text,
                    userInput2.Text,
                    userInput3.Text
                    );
            }
            catch (Exception)
            {
                outputField.Text = "Invalid input";
            }
        }
コード例 #6
0
        private void concatBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (
                    userInput1.Text == "" &&
                    userInput2.Text == "" &&
                    userInput3.Text == ""
                    )
                {
                    throw new Exception();
                }

                outputField.Text =
                    TextCalculator.ConcatStrings(
                        TextCalculator.ConcatStrings(userInput1.Text, userInput2.Text),
                        userInput3.Text
                        );
            }
            catch (Exception)
            {
                outputField.Text = "Enter text first";
            }
        }