Exemple #1
0
        protected override void Operar()
        {
            bool A, B, C;

            A = double.TryParse(Argumento, out number);
            B = Argumento.Equals(ArgDefecto);
            C = Argumento.Equals($"{ModuloCancelativo}");

            if (C)
            {
                Result = "Math ERROR";
            }
            else if (A)
            {
                double Arg = double.Parse(Argumento);

                if (Arg < 1)
                {
                    Result = "Math ERROR";
                }
                else
                {
                    Result = $"{Math.Log(Arg)}";
                }
            }

            else if (B)
            {
                Result = $"{ModuloCancelativo}";
            }
            else
            {
                Result = new ProductoEntero(Coeficiente, Foco).Result;
            }
        }
Exemple #2
0
        }//OK

        private static void TEST_ENTITY_Producto(string Uno, string Dos)
        {
            ProductoEntero Producto = new ProductoEntero(Uno + "*" + Dos + "*" + Dos + "*" + Dos);

            Console.WriteLine(Producto.Nombre);
            Console.WriteLine(Producto.Result);
        }
Exemple #3
0
        private void ObtenerPartes()
        {
            bool A; Coeficiente            = $"{Operacion.Modulo}"; ParteLiteral = "";
            List <PotenciaEntera> Temporal = new List <PotenciaEntera>();

            Proceso.CopyList(Temporal, Elementos);

            foreach (var elemento in Temporal)
            {
                A = double.TryParse(elemento.Result, out number);

                //PULIR BIEN PRODUCTO PARAR RESPONDER CORRECTAMENTE
                if (A)
                {
                    Coeficiente = new ProductoEntero(Coeficiente, elemento.Result).Result;
                    Elementos.Remove(elemento);
                }
                else
                {
                    ParteLiteral += $"{elemento.Result}{Simbolo}";
                }
            }

            Elementos.Add(new PotenciaEntera(Coeficiente));
            ParteLiteral = new ProductoEntero(ParteLiteral.Trim(Simbolo)).Result;
        }
Exemple #4
0
 protected override void Operar()
 {
     Potencia = new PotenciaEntera(Foco);
     if (double.TryParse(Argumento, out number))
     {
         Result = new PotenciaEntera(Valor, Argumento).Result;
     }
     else
     {
         Result = new ProductoEntero(Coeficiente, Potencia.Result).Result;
     }
 }
Exemple #5
0
        private static void TEST_Consola_Producto()
        {
            string Entrada = "(((x*2)*2)*({x}^{2}))";

            //Entrada = "((x*2)*4)*y";
            //Entrada = "x*2*2*y";
            //Entrada = "sen<x*2*4>";
            Console.WriteLine($"ENTRADA = {Entrada}");
            ProductoEntero PRODUCTO = new ProductoEntero(Entrada);

            Console.WriteLine(PRODUCTO.Nombre);
            Console.WriteLine(PRODUCTO.Result);
            Console.WriteLine("----------------------------------");
            Console.ReadKey();
        }
Exemple #6
0
        public Monomios(string Expresion)
        {
            Operacion = new ProductoEntero();

            if (Proceso.IsAgrupate(Expresion))
            {
                Expresion = Proceso.DescorcharA(Expresion);
            }

            Contenido = Expresion;

            Niveles = ObtenerNiveles(Contenido);
            Orden   = ObtenerOrden(Niveles);
            ObtenerElementos(Contenido);
        }
Exemple #7
0
        public Monomios(string Coeficiente, string Literal)
        {
            if (Proceso.IsAgrupate(Coeficiente))
            {
                Coeficiente = Proceso.DescorcharA(Coeficiente);
            }

            if (Proceso.IsAgrupate(Literal))
            {
                Literal = Proceso.DescorcharA(Literal);
            }

            Operacion = new ProductoEntero();
            Contenido = new ProductoEntero(Coeficiente, Literal).Result;

            ObtenerElementos(Contenido);
        }
Exemple #8
0
        public void SetCoeficiente(string Coeficiente)
        {
            if (Proceso.IsAgrupate(Coeficiente))
            {
                Coeficiente = Proceso.DescorcharA(Coeficiente);
            }

            if (Coeficiente.Equals("1"))
            {
                Contenido = new ProductoEntero(Coeficiente, Contenido).Result;
            }
            else
            {
                Contenido = Contenido.Replace(this.Coeficiente, Coeficiente);
            }

            this.Coeficiente = Coeficiente;
            Foco             = SimboloExtendido + Argumento + Cl;
            Operar();
        }
Exemple #9
0
        protected override void Operar()
        {
            bool A, B;

            A = double.TryParse(Argumento, out number);
            B = Argumento.Equals(ArgDefecto);

            if (A)
            {
                double Arg = double.Parse(Argumento);
                Result = $"{Math.Sin(Arg)}";
            }

            else if (B)
            {
                Result = $"{Modulo}";
            }
            else
            {
                Result = new ProductoEntero(Coeficiente, Foco).Result;
            }
        }
Exemple #10
0
        public Derivadas(Monomios MONO, Variables Var)
        {
            if (!MONO.Result.Contains(Var.Nombre))
            {
                Result = "0";
            }
            else
            {
                List <string> DerivadasIndividuales = new List <string>();

                foreach (var item in MONO.Elementos)
                {
                    if (!item.Result.Contains(Var.Nombre))
                    {
                        DerivadasIndividuales.Add(item.Result);
                    }
                    else
                    {
                        //PULIR BIEN SUMAS PARA QUE RETORNE LO NECESARIO POR ESTA CLASE
                        string NewExponente   = new SumaEntera(item.Exponente, "-1").Result;
                        string NewCoeficiente = item.Exponente;
                        string NewPotencia    = new PotenciaEntera(item.Base, NewExponente).Result;

                        DerivadaInterna = new ProductoEntero(NewCoeficiente, NewPotencia).Result;
                        DerivadasIndividuales.Add(DerivadaInterna);
                    }
                }

                Result = "1";
                foreach (var item in DerivadasIndividuales)
                {
                    Result = new ProductoEntero(Result, item).Result;
                }

                //Result = OperarSignos(Result);
            }
        }
Exemple #11
0
        //FIN MANEJO DE DATOS

        public string Procesar(string Expresion, string NombreVariable, string Operacion)
        {
            //IDENTIFICAR OPERACIONES A REALIZAR E IR ALMACENANDO PASOS (CUANDO AL INGRESAR POR UNA FUNCION RETORNE ALGO DIFERENTE AL INCICIAL
            Variables Var = new Variables(NombreVariable);

            Conexion.Open();
            Funcion_id   = DAL.SiguienteFuncion();
            Resultado_id = DAL.SiguienteResultado();
            Conexion.Close();

            LPasos    = new List <Pasos>();
            Entrada   = Expresion;
            Polinomio = new Polinomios(Entrada);
            CrearFuncion(Funcion_id, Polinomio.Nombre, Expresion);

            RegistrarPaso(Entrada, Polinomio.Result, Polinomio.Nombre);

            if (Operacion.Contains("Der"))
            {
                Derivada = new Derivadas(Polinomio, Var);

                RegistrarPaso(Polinomio.Result, Derivada.Result, Derivada.Nombre);

                Salida = Derivada.Result;
                CrearResultado(Resultado_id, Derivada.Nombre, Derivada.Result, Estado);
                //SE DEFINE EL RESULTADO
            }
            else if (Operacion.Contains("Simp"))
            {
                string Temp = "";
                foreach (var mono in Polinomio.Elementos)
                {
                    Op = new ProductoEntero(mono.Result);
                    if (!Op.Result.Equals(mono.Result))
                    {
                        CrearResultado(Resultado_id, Op.Nombre, Op.Result, Estado);

                        RegistrarPaso(mono.Result, Op.Result, Op.Nombre);
                    }
                    Temp = Op.Result;

                    Op = new PotenciaEntera(Op.Result);
                    if (!Op.Equals(Temp))
                    {
                        CrearResultado(Resultado_id, Op.Nombre, Op.Result, Estado);

                        RegistrarPaso(mono.Result, Op.Result, Op.Nombre);
                    }
                    Temp = Op.Result;

                    Op = new CocienteEntero(Op.Result);
                    if (!Op.Equals(Temp))
                    {
                        CrearResultado(Resultado_id, Op.Nombre, Op.Result, Estado);

                        RegistrarPaso(mono.Result, Op.Result, Op.Nombre);
                    }
                    Temp = "";
                }
                //SE DEFINE EL RESULTADO
            }

            //LISTOS ELEMENTOS NECESARIOS PARA GUARDAR REGISTROS
            return(Resultado.Contenido);
        }
Exemple #12
0
        protected override void ObtenerElementos(string Expresion)
        {
            Elementos.Clear();

            //TENER EN CUENTA CUANDO NIVELES ES VACIO, ESTA SENTENCIA IF PARECE SOLUCIONARLO
            if (!Niveles.Contains("0"))
            {
                Elementos.Add(new PotenciaEntera(Contenido));
                ObtenerPartes();
                Result = Contenido;
            }
            else
            {
                char   FirstNivel = Orden.ElementAt(Orden.Length - 1);
                string Foco;
                int    Inicio, i, j, k;
                i = 0; Inicio = 0;
                bool Seguir;

                foreach (var nivel in Niveles)
                {
                    ++i;
                    Seguir = true;
                    if (nivel.Equals(FirstNivel))
                    {
                        j = 0; k = 0;
                        while (Seguir)
                        {
                            if (Contenido.ElementAt(k).Equals(Simbolo))
                            {
                                ++j;
                            }

                            if (j == i)
                            {
                                Seguir = false;
                            }
                            else
                            {
                                ++k;
                            }
                        }

                        Foco   = Contenido.Substring(Inicio, (k - Inicio));
                        Inicio = k + 1;

                        Potencia = new PotenciaEntera(Foco);
                        Elementos.Add(Potencia);
                    }
                }

                //TOMA EL ULTIMO ELEMENTO
                Foco     = Contenido.Substring(Inicio);
                Potencia = new PotenciaEntera(Foco);
                Elementos.Add(Potencia);
                //FIN DE TOMA

                ObtenerPartes();
                //PULIR PRODUCTO PARA RESPONDER CORRECTAMENTE A ESTE PROBLEMA
                Operacion = new ProductoEntero(Coeficiente, ParteLiteral);
                Result    = Operacion.Result;
            }
        }
Exemple #13
0
 public Monomios()
 {
     Operacion    = new ProductoEntero();
     Coeficiente  = "1";
     ParteLiteral = "1";
 }