sallam-ahmed / Polynomial-Calculator

Data Structure 2015 Course Project
Apache License 2.0
0 stars 3 forks source link

Free term input bug #13

Closed sallam-ahmed closed 8 years ago

sallam-ahmed commented 8 years ago

Problem when inputting free term in rich text format

Parser current method: Line: 438 in MainForm

       internal Polynomial PolynomialParse(RichTextBox _rtBox)
       {
           string _deg = "", _coeff = "";
           SortedList<int, Complex> sList = new SortedList<int, Complex>();
           for (int i = 0; i < _rtBox.TextLength; i++)
           {
               _rtBox.SelectionStart = i;
               _rtBox.SelectionLength = 1;
               if (_rtBox.SelectionCharOffset > 0)
               {
                   _deg += _rtBox.SelectedText;
               }
               else
               {
                   if ((_rtBox.SelectedText == "X" || _rtBox.SelectedText == "x"))
                   {
                       continue;
                   }
                   else if (_rtBox.SelectedText != "+" && _rtBox.SelectedText != "-")
                   {
                       _coeff += _rtBox.SelectedText;
                   }
                   else
                   {
                       sList.Add(int.Parse(_deg), new System.Numerics.Complex(double.Parse(_coeff), 0));
                       _deg = "";
                       _coeff = "";
                   }
               }
           }
           sList.Add(int.Parse(_deg), new System.Numerics.Complex(double.Parse(_coeff), 0));
           return new Polynomial(sList);
       }

Produces error: Input string wasn't in a correct format

image

faroukm15 commented 8 years ago

Fixed in last commit.

khaledkee commented 8 years ago

To close an issue in a commit. Add a line fixes #[issue number], instead of closing the issue manually. To demonstrate, replace [issue number] with 13 in a new commit in your branch before merging. @faroukm15