Ejemplo n.º 1
0
        /// <summary>
        /// Constructs given string to equation elements list, finds mistakes and correct them
        /// </summary>
        /// <param name="eq">String that will be convert to equation elements list.</param>
        /// <param name="ns">Numeral system </param>
        public Equation(string eq, Numeral_System ns, string[] Commas_Type)
        {
            the_Equation = eq;

            _Numerical_System = ns;

            _Parser = new Parser(_Numerical_System, Commas_Type);

            Element_Selector();

            try
            {
                Integrity_Check();
            }
            catch (EquationIsEmptyException)
            {
                IMessage_Box Message_Box = Factory.Get_Message_Box;

                Message_Box.Pop_Up("Given equation to solve is empty or correction of incorrectly written equation " +
                                   "text left no elements in the equation.");
                Element_Colection = new Equation_Elements {
                    new Number(0)
                };
            }

            Bracket_Pairer();
        }
        internal Item_Numeral_System_List(Numeral_System_List_Context _Numeral_System_List_Context, sbyte numeral_System_Code, IStandard_Messages_Translate Standard_Messages)
        {
            Numeral_System_List_Context = _Numeral_System_List_Context;

            Numeral_System_Code = numeral_System_Code;

            Content_Text = Numeral_System.Numeral_System_Dictionary_Name(Numeral_System_Code, Standard_Messages);
        }
        /// <summary>
        /// Creates new numerical system for main window.
        /// </summary>
        /// <param name="ns">Base of new numeral system or encoded number for exotic numeral system(check Numerical_System description).</param>
        public void Set_Numeral_System(sbyte new_Numeral_System_Code)
        {
            Numeral_System_Code = new_Numeral_System_Code;

            Current_Numeral_System = new Numeral_System(Numeral_System_Code);

            Parser = new Parser(Current_Numeral_System, Commas_Type_Array);

            Back_Parser = new Back_Parser_Fascede(Number_Notation, Numeral_System_Code, Comma_Type);
        }
        /// <summary>
        /// Sets texts for list_Item in Numeral_System_Items_List.
        /// </summary>
        public void Set_Numeral_System_Texts(IStandard_Messages_Translate standard_Messages)
        {
            foreach (Numeral_System_List_Content list_Content in Numeral_System_List_Items_List)
            {
                if (list_Content is Item_Numeral_System_List list_Item)
                {
                    string new_Numeral_System_Name = Numeral_System.Numeral_System_Dictionary_Name(
                        list_Item.Numeral_System_Code, standard_Messages);

                    list_Item.Set_Numeral_System_Name(new_Numeral_System_Name);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Converts the character representation of a number in given numeral system to its
 /// signed byte number equivalent.
 /// </summary>
 /// <exception cref="ParsingCharacterIsNoDigitException">
 /// The Exception that is thrown when character that is to be parsed to digit is corresponding
 ///  no digit from current numerical system.
 /// </exception>
 public sbyte Digit_Parse(char digit, Numeral_System _Numeral_System)
 {
     if (digit >= '0' && digit <= '9' && digit < _Numeral_System.System_Type + 48)
     {
         return((sbyte)(digit - '0'));
     }
     else if (digit >= 'A' && digit <= 'Z' && digit < _Numeral_System.System_Type + 55)
     {
         return((sbyte)(digit - 55));                // 'A' = 10 - 'Z' 35
     }
     else if (digit >= 'a' && digit <= '|' && digit < _Numeral_System.System_Type + 61)
     {
         return((sbyte)(digit - 61));                // 'a' = 36 - 'z' = 61, '}' = 62, '|' =  63
     }
     else
     {
         throw new ParsingCharacterIsNoDigitException($"{digit} is not a digit");
     }
 }
Ejemplo n.º 6
0
        public Parser(Numeral_System numeral_System, string[] _Commas_Type)
        {
            Numeral_System = numeral_System;

            Commas_Type = _Commas_Type;
        }
 /// <summary>
 /// Constructs new instance of Converter converting given text string parsing to switch calculation mode
 /// to single by solving more complex one or single operation as it would be weitten in single mode.
 /// </summary>
 internal Complex_To_Single_WorkSpace_Converter(string equation, Numeral_System numeral_System, string[] Commas_Type, MainWindow _MainWindow)
     : base(equation, numeral_System, Commas_Type)
 {
     MainWindow = _MainWindow;
 }