Exemplo n.º 1
0
 /// <summary>
 /// Event and exception handler for array sorting functoins
 /// </summary>
 /// <param name="sender">Pressed button name</param>
 private void SortArray(object sender, EventArgs e)
 {
     try
     {
         if (FirstValue.Text.Equals(""))
         {
             throw new Exception("Input field is empty");
         }
         var      validator = new Validator();
         double[] argument  = validator.ValidateArray(FirstValue.Text);
         string   operation = ((Button)sender).Name;
         var      op        = ArraySortFactory.CreateCalculator(operation);
         op.Calculate(argument);
         Result.Text = "";
         for (Int16 i = 0; i < argument.Length; i++)
         {
             Result.Text += Convert.ToString(argument[i]);
             Result.Text += ", ";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "You are a clayfish", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Array sorting method
 /// </summary>
 /// <param name="sender">
 /// Button sender
 /// </param>
 /// <param name="e">
 /// Operation name
 /// </param>
 public void ArraySort(object sender, EventArgs e)
 {
     try
     {
         double[] mas        = ValidationArrays.GetArray(InputFirstTextBox);
         string   nameButton = ((Button)sender).Name;
         ISorter  Factory    = ArraySortFactory.CreateSort(nameButton);
         double[] massive    = Factory.Sort(mas);
         string   result     = "";
         for (int j = 0; j < massive.Length; j++)
         {
             result += Convert.ToString(massive[j] + " ");
         }
         Result.Text = result;
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 3
0
 public void OperationForLog()
 {
     Type resultType = ArraySortFactory.CreateSort("SelectSort").GetType();
 }
Exemplo n.º 4
0
        public void FactoryTest(Type type, string name)
        {
            Type resultType = ArraySortFactory.CreateSort(name).GetType();

            Assert.AreEqual(type, resultType);
        }
Exemplo n.º 5
0
 public void Initialize()
 {
     Sorter = ArraySortFactory.CreateCalculator("SlowSort");
 }
Exemplo n.º 6
0
 public ArraySortUI(ArraySortFactory sortFactory, int tableWith) : base(tableWith)
 {
     _sortFactory = sortFactory;
 }