Beispiel #1
0
        private void BtnResultado_Click(object sender, EventArgs e)
        {
            segundo = double.Parse(TxtBPantalla.Text);

            double Suma;
            double Resta;
            double Multiplicacion;
            double Division;

            switch (operador)
            {
            case "+":
                Suma = obj.Sumar((primero), (segundo));
                TxtBPantalla.Text = Suma.ToString();
                break;

            case "-":
                Resta             = obj2.Restar((primero), (segundo));
                TxtBPantalla.Text = Resta.ToString();
                break;

            case "*":
                Multiplicacion    = obj3.Multiplicacion((primero), (segundo));
                TxtBPantalla.Text = Multiplicacion.ToString();
                break;

            case "/":
                Division          = obj4.Division((primero), (segundo));
                TxtBPantalla.Text = Division.ToString();
                break;
            }
        }
Beispiel #2
0
 private void butonresta_Click(object sender, EventArgs e)
 {
     ingresoR    = new Resta();
     ingresoR.V3 = double.Parse(textboxA.Text);
     ingresoR.V4 = double.Parse(textbox2.Text);
     label3.Text = ingresoR.CalcularR().ToString();
 }
Beispiel #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     ingreso2    = new Resta();
     ingreso2.N1 = double.Parse(textBox1.Text);
     ingreso2.N2 = double.Parse(textBox2.Text);
     label4.Text = ingreso2.calcular().ToString();
 }
Beispiel #4
0
        public static void restar()
        {
            string linea2     = "";
            int    aux        = 0;
            string urlAddress = "https://calculadora20190401125057.azurewebsites.net/Calculadora/Restar";
            Resta  resta      = new Resta();

            Console.WriteLine("Escribe los números que quieres restar");
            // El usuario introduce dos números para restar, si mete valores no numéricos no se guardan.
            do
            {
                linea2 = Console.ReadLine();

                if (aux == 0)
                {
                    resta.minuendo = linea2;
                }
                else
                {
                    resta.sustraendo = linea2;
                }

                aux++;
            } while (aux < 2);

            sendJson(urlAddress, resta);
        }
Beispiel #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     ingresar    = new Resta();
     ingresar.R1 = double.Parse(textBox1.Text);
     ingresar.R2 = double.Parse(textBox2.Text);
     label3.Text = ingresar.Calcular().ToString();
 }
       // private Enumerados.Operadores miOperador;
      //  private double operando;
       // private double operandoDos;

        public double RealizarLaOperacionBinaria(Enumerados.Operadores miOperador, double operando, double operandoDos)
        {
            double resultado = 0.0;
            switch (miOperador)
            {

                case Enumerados.Operadores.Suma:
                    var laSuma = new Suma();
                    resultado = laSuma.Calculo(operando, operandoDos);
                    break;


                case Enumerados.Operadores.Resta:
                    var laResta = new Resta();
                    resultado = laResta.Calculo(operando, operandoDos);
                    break;


                    /*case Enumerados.Operadores.Multiplicacion:
                        var laMultiplicacion = new Multiplicacion();
                        resultado = laMultiplicacion.Calculo(operando, operandoDos);
                        break;
                        */





            }
            return resultado;
        }
        public String Restar(double[] numeros)
        {
            // Creo objeto Nlog y escribo la operación en el registro la operación.
            var logger = NLog.LogManager.GetCurrentClassLogger();

            string json       = "";
            double minuendo   = 0;
            double sustraendo = 0;
            Resta  desRest    = new Resta();
            Random random     = new Random();

            id = random.Next(0, 100);

            // Recibe el objeto en formato JSON y lo almaceno en un objeto de tipo Resta.
            using (var streamReader = new StreamReader(HttpContext.Request.Body))
            {
                var result = streamReader.ReadToEnd();
                try
                {
                    desRest    = JsonConvert.DeserializeObject <Resta>(result);
                    minuendo   = Double.Parse(desRest.minuendo);
                    sustraendo = Double.Parse(desRest.sustraendo);

                    desRest.resultado = WebApplication1.Models.Calculadora.resta(minuendo, sustraendo);



                    // Creo un objeto operacion y almaceno sus datos
                    op.Tipo = "Rest";

                    op.Calculo += desRest.minuendo + " - " + desRest.sustraendo + " = " + desRest.resultado;



                    logger.Info("Operación de Resta");

                    DateTime fecha = DateTime.Now;

                    op.Fecha = Convert.ToString(fecha);

                    // Convierto el objeto a JSON y lo añado la operación al listado general

                    JournalList.Listado.Add(JournalList.id, JsonConvert.SerializeObject(op));


                    // Añado nuevas propiedades al objeto, lo serializo y lo envío

                    Response.Clear();
                    Response.ContentType = "application/json; charset=utf-8";
                    var json2 = JsonConvert.SerializeObject(desRest);
                    Response.WriteAsync(json2);
                } catch
                {
                    Error500();
                }
            }


            return("");
        }
Beispiel #8
0
        private void btnResta_Click(object sender, EventArgs e)
        {
            resta    = new Resta();
            resta.R1 = int.Parse(txtValorA.Text);
            resta.R2 = int.Parse(txtValorB.Text);

            lblResultado.Text = "Resultado: " + resta.Restar().ToString();;
        }
Beispiel #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            rest     = new Resta();
            rest.R11 = double.Parse(txtValA.Text);
            rest.R21 = double.Parse(txtValB.Text);

            lblResult.Text = Convert.ToString(rest.Calcular());
        }
Beispiel #10
0
        public Weapon Licuar(Pato pato, Weapon weapon, Resta resta)
        {
            int    entero1 = pato.Name.Length;
            string texto   = weapon.Name;
            float  numero  = resta.ObtenerValorActual();

            return(new Arco());
        }
Beispiel #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            Resta ingreso = new Resta();

            ingreso.V1    = double.Parse(textvalA.Text);
            ingreso.V2    = double.Parse(textvalB.Text);
            lblResul.Text = ingreso.CalcularResta().ToString();
        }
Beispiel #12
0
            public static Resta operator +(Resta r1, Resta r2)
            {
                Resta nc = new Resta();

                nc.real = r1.real - r2.real;

                nc.imag = r1.imag - r2.imag;

                return(nc);
            }
        private void Buttonigual_Click(object sender, RoutedEventArgs e)
        {
            num2 = Double.Parse(resTextBox.Text);

            double Suma;
            double Resta;
            double Multiplicacion;
            double Division;

            switch (Operation)
            {
            case "+":
                Suma            = op1.Sum((num1), (num2));
                resTextBox.Text = Suma.ToString();

                break;

            case "-":
                Resta           = op2.Res((num1), (num2));
                resTextBox.Text = Resta.ToString();
                break;

            case "*":
                Multiplicacion  = op3.Multi((num1), (num2));
                resTextBox.Text = Multiplicacion.ToString();
                break;

            case "/":
                if (num2 == 0)
                {
                    MessageBox.Show("SYSTEM ERROR");
                    resTextBox.Clear();
                }
                else
                {
                    Division        = op4.Div((num1), (num2));
                    resTextBox.Text = Division.ToString();
                }
                break;

            case " ":

                MessageBox.Show("no se encontro en numero secundario");


                break;
            }
        }
Beispiel #14
0
            static void Main(string[] args)
            {
                Suma S = new Suma();

                S.Fa1 = 520;
                S.Fa2 = 680;
                S.Operar();
                Console.WriteLine("La suma de " + S.Fa1 + " + " + S.Fa2 + " = " + S.R);
                Resta Rs = new Resta();

                Rs.Fa1 = 1349;
                Rs.Fa2 = 253;
                Rs.Operar();
                Console.WriteLine("La resta de " + Rs.Fa1 + " - " + Rs.Fa2 + " = " + Rs.R);
                Console.ReadKey();
            }
Beispiel #15
0
        public void menuSub(int tipoDato)
        {
            Suma           sum  = new Suma();
            Resta          res  = new Resta();
            multiplicacion mult = new multiplicacion();
            Division       div  = new Division();
            char           Option;

            do
            {
                Console.WriteLine("\n***Bienvendido***\n");
                Console.WriteLine("\n**Calculadora**\n" +
                                  "\n1--Suma--\n" +
                                  "\n2--Resta--\n" +
                                  "\n3--Multiplicacion--\n" +
                                  "\n4--Division--\n");
                Option = Console.ReadKey().KeyChar;
                Console.ReadKey();
                switch (Option)
                {
                case '1':
                    sum.operacion(tipoDato);
                    Console.ReadKey();
                    break;

                case '2':
                    res.operacion(tipoDato);
                    Console.ReadKey();
                    break;

                case '3':
                    mult.operacion(tipoDato);
                    Console.ReadKey();
                    break;

                case '4':
                    div.operacion(tipoDato);

                    break;

                default:
                    Console.WriteLine("\nPor favor ingrese una opcion valida\n");
                    break;
                }
            } while (Option != 5);
        }
Beispiel #16
0
        private void btnResta(object sender, EventArgs e)
        {
            Double n1, n2, Resta;

            n1    = Convert.ToDouble(txtNum1.Text);
            n2    = Convert.ToDouble(txtNum2.Text);
            Resta = n1 - n2;
            labelResultado.Text = Resta.ToString();
            if (txtNum1.Text == "")
            {
                labelResultado.Text = "No hay numero 1";
            }
            else if (txtNum2.Text == "")
            {
                labelResultado.Text = "No hay numero 2";
            }
        }
        // private Enumerados.Operadores miOperador;
        //  private double operando;
        // private double operandoDos;

        public double RealizarLaOperacionBinaria(Enumerados.Operadores miOperador, double operando, double operandoDos)
        {
            double resultado = 0.0;

            switch (miOperador)
            {
            case Enumerados.Operadores.Suma:
                var laSuma = new Suma();
                resultado = laSuma.Calculo(operando, operandoDos);
                break;

            case Enumerados.Operadores.Resta:
                var laResta = new Resta();
                resultado = laResta.Calculo(operando, operandoDos);
                break;
            }
            return(resultado);
        }
    // Update is called once per frame
    void Update()
    {
        tiempo += Time.deltaTime;
        if (miedo > 0)
        {
            /*Llamando a una funcion, se aumentara la velocidad en el que el personaje deje de tener MIEDO dependiendo de
             * cuantos enemigos haya matado hasta ahora  ///////////////// ((PROGRAMACION FUNCIONAL))  8*/
            miedo = (float)Resta.fres(miedo, BajandoMiedo.bajandoMiedo(enemigosMuertos));
            //Debug.Log( BajandoMiedo.bajandoMiedo(enemigosMuertos));
        }
        else
        {
            tiempo = 0;
        }

        miedo = Mathf.Clamp(miedo, 0, 100);
        //Llamando una funcion se realizara una division para ajustar la barra de medicion de MIEDO en la Interfaz ((PROGRAMACION FUNCIONAL))  9
        barraMiedo.fillAmount = (float)Division.fdiv(miedo, 100);
    }
Beispiel #19
0
            static void Main(string[] args)
            {
                Suma suma1 = new Suma();

                suma1.Valor1 = 10;
                suma1.Valor2 = 7;
                suma1.Operar();
                Console.WriteLine("La suma de " + suma1.Valor1 + " y " +
                                  suma1.Valor2 + " es " + suma1.Resultado);

                Resta resta1 = new Resta();

                resta1.Valor1 = 8;
                resta1.Valor2 = 4;
                resta1.Operar();
                Console.WriteLine("La diferencia de " + resta1.Valor1 +
                                  " y " + resta1.Valor2 + " es " + resta1.Resultado);

                Console.ReadKey();
            }
Beispiel #20
0
        private void Btnigual_Click(object sender, EventArgs e)
        {
            Segundo = double.Parse(Txtmostrar.Text);

            double Suma;
            double Resta;
            double Division;
            double Multiplicacion;


            switch (Operando)
            {
            case "+":
            {
                Suma            = Operador.Sumar((Primero), (Segundo));
                Txtmostrar.Text = Suma.ToString();
            }
            break;

            case "-":
            {
                Resta           = Operador.Restar((Primero), (Segundo));
                Txtmostrar.Text = Resta.ToString();
            }
            break;

            case "/":
            {
                Division        = Operador.Dividir((Primero), (Segundo));
                Txtmostrar.Text = Division.ToString();
            }
            break;

            case "*":
            {
                Multiplicacion  = Operador.Multiplicar((Primero), (Segundo));
                Txtmostrar.Text = Multiplicacion.ToString();
            }
            break;
            }
        }
    public void OnTriggerStay(Collider other)
    {
        Debug.Log(other.tag);
        if (other.CompareTag("tagEnemigo"))
        {
            Debug.Log("ALGO Tagherir");
            if (bloq == 0)
            {
                //Llamando a una funcion, se aumenta el MIEDO del personaje cuando lo toque un enemigo((PROGRAMACION FUNCIONAL)) 4
                estadisticas.miedo = (float)Suma.fsum(estadisticas.miedo, 30);

                /*Se disminuye la velocidad en la que se mueve el personaje llamando una funcion para que multiplique y reste velocidad. Dependiendo
                 * del MIEDO del personaje bajara aun mas ////////////////////////((PROGRAMACION FUNCIONAL))  5*/
                movimient.velocidadMovimiento = movimient.velocidadMovimiento - ((float)Multiplicacion.fmul(estadisticas.miedo, 0.1));

                bloq = 1;
            }
        }
        if (other.CompareTag("tagDaño"))
        {
            if (bloq == 0)
            {
                tiempo = 0;
                if (estadisticas.miedo <= 0)
                {
                    vida = (float)Resta.fres(vida, 20);//Llamando a una funcion, se le resta vida a el Personaje ((PROGRAMACION FUNCIONAL))  6
                }
                else
                {
                    //Llamando a una funcion, Se le resta vida al personaje dependiendo si tiene MIEDO se le restara aun MAS ((PROGRAMACION FUNCIONAL))  7
                    vida = (float)Resta.fres(vida, VulnerabilidadMiedo.bajandoVidaMiedo(estadisticas.miedo, 20));
                }
                bloq = 1;
            }
        }
        if (other.CompareTag("tagMaderaClavos"))
        {
            equipo.AgregandoObjeto("01");
            Destroy(other.transform.gameObject);
        }
    }
Beispiel #22
0
        static void Main(string[] args)
        {
            Sumando totalsuma = new Sumando(5, 8);

            totalsuma.getSuma();
            Resta totalresta = new Resta(5, 8);

            totalresta.getResta();
            Multi totalmulti = new Multi(5, 8);

            totalmultu.getMulti();
            Divi totaldivi = new Divi(5, 8);

            totaldivi.getDivi();


            Console.WriteLine("suma" + totalsuma.getSuma());
            Console.WriteLine("Resta" + totalresta.getResta());
            Console.WriteLine("Multiplicacion" + totalmulti.getMulti());
            Console.WriteLine("Divicion" + totaldivi.getDivi());
        }
    public void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("tagArmaBlanca"))
        {
            Debug.Log("ALGO");
            if (other.transform.GetComponent <golpeArmaBlanca>().golpeandoArmaBlanca == 1 && bloq == 0)
            {
                player = other.transform;

                if (other.transform.root.GetComponent <EstadisticasPlayer>().miedo <= 0)
                {
                    vida = Resta.fres(vida, 40);////////////////////////////////////////////FUNCIONAL
                }
                else
                {
                    //Llamando a una funcion, se le resta MENOS vida a el Enemigo dependiendo de el MIEDO del Personaje ((PROGRAMACION FUNCIONAL))  10
                    vida = Resta.fres(vida, GolpeMiedo.calculandoDanio(other.transform.root.GetComponent <EstadisticasPlayer>().miedo, 40));
                }
                bloq = 1;
            }
        }
    }
        static void Main(string[] args)
        {
            Suma     s1 = new Suma();
            Resta    r1 = new Resta();
            Producto p1 = new Producto();

            s1.Nro1 = 15;
            s1.Nro2 = 10;
            s1.operar();
            s1.imprimir();

            r1.Nro1 = 10;
            r1.Nro2 = 16;
            r1.operar();
            r1.imprimir();

            p1.Nro1 = -10;
            p1.Nro2 = 11;
            p1.operar();
            p1.imprimir();
            Console.ReadKey();
        }
Beispiel #25
0
            static void Main(string[] args)
            {
                //Parametros por ref
                Cuadrado q = new Cuadrado();
                int      x = 3;

                Console.WriteLine("con x = 3");
                q.cuadrado(x);
                Console.WriteLine("Pase de parametros: " + x);

                q.cuadradoR(ref x);
                Console.WriteLine("Pase de parametros por ref: " + x);

                Console.WriteLine("/////"); //Espacio

                //Parametros por out
                int num1 = 15;
                int num2 = 10;
                int r;

                suma(num1, num2, out r);

                Console.WriteLine("Suma de 10 + 15 usando");
                Console.WriteLine("Pase de parametros: " + r);
                Console.WriteLine("Pase de parametros por out: " + suma(num1, num2));

                Console.WriteLine("/////"); //Espacio

                //Parametros por in

                Console.WriteLine("Usando in");
                Resta y = new Resta();
                int   n = 2;

                n = n - 1;
                y.resul(in n);
                Console.WriteLine(n);
            }
 /// <summary>
 /// Establece un automata donde contenedremos todas las gramaticas clases que se establecieron
 /// </summary>
 public Lenguaje()
 {
     //Establecemos una lista de las gramaticas que contiene el automata
     gramaticas[0]  = new And();
     gramaticas[1]  = new Boolean_();
     gramaticas[2]  = new Cadena();
     gramaticas[3]  = new Chart();
     gramaticas[4]  = new Colon();
     gramaticas[5]  = new ComentarioUnaLinea();
     gramaticas[6]  = new ComentarioVariasLineas();
     gramaticas[7]  = new Comparacion();
     gramaticas[8]  = new Decimal_();
     gramaticas[9]  = new Desde();
     gramaticas[10] = new Diferente();
     gramaticas[11] = new Disminuir();
     gramaticas[12] = new Division();
     gramaticas[13] = new Entero();
     gramaticas[14] = new Hacer();
     gramaticas[15] = new Hasta();
     gramaticas[16] = new Igual();
     gramaticas[17] = new Incrementar();
     gramaticas[18] = new Incremento();
     gramaticas[19] = new Mayor();
     gramaticas[20] = new MayorIgual();
     gramaticas[21] = new Menor();
     gramaticas[22] = new MenorIgual();
     gramaticas[23] = new Mientras();
     gramaticas[24] = new Multiplicacion();
     gramaticas[25] = new Negacion();
     gramaticas[26] = new Or();
     gramaticas[27] = new ParentesisAbrir();
     gramaticas[28] = new ParentesisCerrar();
     gramaticas[29] = new Resta();
     gramaticas[30] = new Si();
     gramaticas[31] = new Sino();
     gramaticas[32] = new Sino_Si();
     gramaticas[33] = new Suma();
 }
        public void RestaUTest()
        {
            // ** Arrange
            // Create instance calculadora
            Resta resta = new Resta();

            // Definir una entrada y una salida
            double expectedResult = 1;
            double input1         = 2;
            double input2         = 1;
            //  Arrange **


            // ** Act
            // Ejecutar el metodo bajo prueba:
            double actualResult = resta.Operar(input1, input2);

            //  Act **

            // ** Assert
            // Verificar el resultado:
            Assert.AreEqual(expectedResult, actualResult);
            // Assert **
        }
Beispiel #28
0
        public object compilar(Entorno ent, Errores errores)
        {
            //CREO MIS UTILIDADES
            //ASIGNACION INICIAL
            AsignacionId target            = new AsignacionId(id, null, linea, columna);
            Asignacion   asignacionInicial = new Asignacion(target, primero, linea, columna);
            //ACTUALIZACION DE LA VARIABLE Y CONDICION A EVALUAR
            Asignacion actualizarVariable;
            Primitivo  valorFAD = new Primitivo(Tipos.INTEGER, "1", linea, columna);
            Expresion  condicion;
            AccessId   left = new AccessId(id, null, linea, columna);

            if (fad.Equals("to"))
            {
                Less menorIgual = new Less(true, left, segundo, linea, columna);
                condicion = (Expresion)menorIgual;
                Suma suma = new Suma(left, valorFAD, linea, columna);
                actualizarVariable = new Asignacion(target, (Expresion)suma, linea, columna);
            }
            else   //downto
            {
                Greater mayorIgual = new Greater(true, left, segundo, linea, columna);
                condicion = (Expresion)mayorIgual;
                Resta resta = new Resta(left, valorFAD, linea, columna);
                actualizarVariable = new Asignacion(target, (Expresion)resta, linea, columna);
            }
            //INICIO LA COMPILACION
            try
            {
                Generator generator = Generator.getInstance();
                generator.addComment("Inicia FOR");
                asignacionInicial.compilar(ent, errores);
                string lblFor = generator.newLabel();
                generator.addLabel(lblFor);
                Retorno retcondicion = condicion.compilar(ent);
                if (retcondicion.type.tipo == Tipos.BOOLEAN)
                {
                    ent.fors.AddLast(new IteFor(true, actualizarVariable));
                    ent.ybreak.AddLast(retcondicion.falseLabel);
                    ent.ycontinue.AddLast(lblFor);
                    generator.addLabel(retcondicion.trueLabel);
                    foreach (Instruccion sentencia in sentencias)
                    {
                        sentencia.compilar(ent, errores);
                    }
                    actualizarVariable.compilar(ent, errores);
                    generator.addGoto(lblFor);
                    generator.addLabel(retcondicion.falseLabel);
                    ent.fors.RemoveLast();
                    ent.ybreak.RemoveLast();
                    ent.ycontinue.RemoveLast();
                    generator.addComment("Finaliza FOR");
                }
                else
                {
                    throw new Error("Semántico", "La condicion a evaluar en el for no es de tipo Boolean", ent.obtenerAmbito(), linea, columna);
                }
            } catch (Error ex)
            {
                errores.agregarError(ex);
            }
            return(null);
        }
Beispiel #29
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            //ADDITION
            Sum s1 = new Sum();

            Sum s2 = new Sum();

            Sum sum = new Sum();

            s1.real = double.Parse(real1.Text);
            s1.imag = double.Parse(imag1.Text);
            s2.real = double.Parse(real2.Text);
            s2.imag = double.Parse(imag2.Text);

            sum = s1 + s2;

            realAdd.Text = sum.real.ToString();
            imagAdd.Text = sum.imag.ToString();


            //SUBTRACTION
            Resta r1 = new Resta();

            Resta r2 = new Resta();

            Resta resta = new Resta();

            r1.real = double.Parse(real1.Text);
            r1.imag = double.Parse(imag1.Text);
            r2.real = double.Parse(real2.Text);
            r2.imag = double.Parse(imag2.Text);

            resta = r1 + r2;

            realRest.Text = resta.real.ToString();
            imagRest.Text = resta.imag.ToString();


            // MULTIPLICATION
            Multiply m1 = new Multiply();

            Multiply m2 = new Multiply();

            Multiply multi = new Multiply();

            m1.real = double.Parse(real1.Text);
            m1.imag = double.Parse(imag1.Text);
            m2.real = double.Parse(real2.Text);
            m2.imag = double.Parse(imag2.Text);

            multi = m1 * m2;

            realMult.Text = multi.real.ToString();
            imagMult.Text = multi.imag.ToString();

            // DIVISION
            Div d1 = new Div();

            Div d2 = new Div();

            Div div = new Div();

            d1.real = double.Parse(real1.Text);
            d1.imag = double.Parse(imag1.Text);
            d2.real = double.Parse(real2.Text);
            d2.imag = double.Parse(imag2.Text);

            div = d1 / d2;

            realDiv.Text = div.real.ToString();
            imagDiv.Text = div.imag.ToString();
        }
Beispiel #30
0
        //En este método se realiza la operación correspondiente a la selección en el combobox de la operación,
        // y en el combobox del tamaño, llamando el método correspondiente desde la librería creada por nosotros
        public void Operacion()
        {
            switch (op)
            {
            case "A+B":
                if (opc == "2x2")
                {
                    matrizC = Suma.DosxDos(matrizA, matrizB);
                }
                else if (opc == "3x3")
                {
                    matrizC = Suma.TresxTres(matrizA, matrizB);
                }
                else if (opc == "4x4")
                {
                    matrizC = Suma.CuatroxCuatro(matrizA, matrizB);
                }
                else if (opc == "5x5")
                {
                    matrizC = Suma.CincoxCinco(matrizA, matrizB);
                }

                break;

            case "B-A":
                if (opc == "2x2")
                {
                    matrizC = Resta.DosxDos(matrizB, matrizA);
                }
                else if (opc == "3x3")
                {
                    matrizC = Resta.TresxTres(matrizB, matrizA);
                }
                else if (opc == "4x4")
                {
                    matrizC = Resta.CuatroxCuatro(matrizB, matrizA);
                }
                else if (opc == "5x5")
                {
                    matrizC = Resta.CincoxCinco(matrizB, matrizA);
                }

                break;

            case "A-B":
                if (opc == "2x2")
                {
                    matrizC = Resta.DosxDos(matrizA, matrizB);
                }
                else if (opc == "3x3")
                {
                    matrizC = Resta.TresxTres(matrizA, matrizB);
                }
                else if (opc == "4x4")
                {
                    matrizC = Resta.CuatroxCuatro(matrizA, matrizB);
                }
                else if (opc == "5x5")
                {
                    matrizC = Resta.CincoxCinco(matrizA, matrizB);
                }

                break;

            case "B*A":
                if (opc == "2x2")
                {
                    matrizC = Multiplicacion.DosxDos(matrizA, matrizB);
                }
                else if (opc == "3x3")
                {
                    matrizC = Multiplicacion.TresxTres(matrizA, matrizB);
                }
                else if (opc == "4x4")
                {
                    matrizC = Multiplicacion.CuatroxCuatro(matrizA, matrizB);
                }
                else if (opc == "5x5")
                {
                    matrizC = Multiplicacion.CincoxCinco(matrizA, matrizB);
                }

                break;

            case "Suma de la diagonal":
                if (opc == "2x2")
                {
                    matrizC = Diagonal.DosxDos(matrizA, matrizB);
                }
                else if (opc == "3x3")
                {
                    matrizC = Diagonal.TresxTres(matrizA, matrizB);
                }
                else if (opc == "4x4")
                {
                    matrizC = Diagonal.CuatroxCuatro(matrizA, matrizB);
                }
                else if (opc == "5x5")
                {
                    matrizC = Diagonal.CincoxCinco(matrizA, matrizB);
                }

                break;
            }
        }
Beispiel #31
0
        /** Method with the actual generated action code. */
        public TUVienna.CS_CUP.Runtime.Symbol CUP_TinyParser_do_action(
            int CUP_TinyParser_act_num,
            TUVienna.CS_CUP.Runtime.lr_parser CUP_TinyParser_parser,
            System.Collections.Stack xstack1,
            int CUP_TinyParser_top)
        {
            /* Symbol object for return from actions */
            mStack CUP_TinyParser_stack = new mStack(xstack1);

            TUVienna.CS_CUP.Runtime.Symbol CUP_TinyParser_result;

            /* select the action based on the action number */
            switch (CUP_TinyParser_act_num)
            {
            /*. . . . . . . . . . . . . . . . . . . .*/
            case 30: // factor ::= error
            {
                Expresion RESULT = null;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(13 /*factor*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 29: // factor ::= IDENTIFICADOR
            {
                Expresion        RESULT = null;
                SimboloAbstracto id     = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Variable(id, id.Linea, id.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(13 /*factor*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 28: // factor ::= LIT_ENTERO
            {
                Expresion        RESULT = null;
                SimboloAbstracto val    = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new NumeroEntero(val, val.Linea, val.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(13 /*factor*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 27: // factor ::= PARENT_IZQ exp PARENT_DER
            {
                Expresion RESULT = null;
                Expresion e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;

                RESULT = e;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(13 /*factor*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 26: // term ::= factor
            {
                Expresion RESULT = null;
                Expresion e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = e;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(12 /*term*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 25: // term ::= term DIVISION factor
            {
                Expresion        RESULT = null;
                Expresion        e1     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto d      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e2     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Division(e1, e2, d.Linea, d.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(12 /*term*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 24: // term ::= term MULTIPLICACION factor
            {
                Expresion        RESULT = null;
                Expresion        e1     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto m      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e2     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Multiplicacion(e1, e2, m.Linea, m.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(12 /*term*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 23: // exp_simple ::= term
            {
                Expresion RESULT = null;
                Expresion e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = e;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(11 /*exp_simple*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 22: // exp_simple ::= exp_simple RESTA term
            {
                Expresion        RESULT = null;
                Expresion        e1     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto r      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e2     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Resta(e1, e2, r.Linea, r.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(11 /*exp_simple*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 21: // exp_simple ::= exp_simple SUMA term
            {
                Expresion        RESULT = null;
                Expresion        e1     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto s      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e2     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Suma(e1, e2, s.Linea, s.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(11 /*exp_simple*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 20: // exp ::= exp_simple
            {
                Expresion RESULT = null;
                Expresion e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = e;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(10 /*exp*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 19: // exp ::= exp_simple IGUAL exp_simple
            {
                Expresion        RESULT = null;
                Expresion        e1     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto i      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e2     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Igual(e1, e2, i.Linea, i.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(10 /*exp*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 18: // exp ::= exp_simple MENOR exp_simple
            {
                Expresion        RESULT = null;
                Expresion        e1     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto m      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e2     = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Menor(e1, e2, m.Linea, m.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(10 /*exp*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 17: // args ::= args COMA exp
            {
                ListaParametros RESULT = null;
                ListaParametros p      = (ListaParametros)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                Expresion       e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                p.agregarElemento(e);
                RESULT = p;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(9 /*args*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 16: // args ::= exp
            {
                ListaParametros RESULT = null;
                Expresion       e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new ListaParametros();
                RESULT.agregarElemento(e);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(9 /*args*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 15: // opt_args ::=
            {
                ListaParametros RESULT = null;

                RESULT = new ListaParametros();

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(8 /*opt_args*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 14: // opt_args ::= args
            {
                ListaParametros RESULT = null;
                ListaParametros p      = (ListaParametros)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = p;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(8 /*opt_args*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 13: // fuction_call ::= IDENTIFICADOR opt_args
            {
                Sentencia        RESULT = null;
                SimboloAbstracto id     = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                ListaParametros  p      = (ListaParametros)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new LLamadaFuncion(id, p, id.Linea, id.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(7 /*fuction_call*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 12: // sent_assign ::= IDENTIFICADOR ASIGNACION exp
            {
                Sentencia        RESULT = null;
                SimboloAbstracto id     = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                SimboloAbstracto a      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                Expresion        e      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Asignacion(new Variable(id, id.Linea, id.Columna), e, a.Linea, a.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(6 /*sent_assign*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 11: // sent_repeat ::= REPITA secuencia_sent HASTA exp
            {
                Sentencia        RESULT = null;
                SimboloAbstracto r      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 3)).value;
                ListaSentencia   s      = (ListaSentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                Expresion        c      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new RepitaHasta(c, s, r.Linea, r.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(5 /*sent_repeat*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 10: // sent_if ::= SI exp ENTONCES secuencia_sent SINO secuencia_sent FIN
            {
                Sentencia        RESULT = null;
                SimboloAbstracto s      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 6)).value;
                Expresion        c      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 5)).value;
                ListaSentencia   en     = (ListaSentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 3)).value;
                ListaSentencia   sn     = (ListaSentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;

                RESULT = new Condicional(c, en, sn, s.Linea, s.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(4 /*sent_if*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 9: // sent_if ::= SI exp ENTONCES secuencia_sent FIN
            {
                Sentencia        RESULT = null;
                SimboloAbstracto s      = (SimboloAbstracto)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 4)).value;
                Expresion        c      = (Expresion)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 3)).value;
                ListaSentencia   en     = (ListaSentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;

                RESULT = new Condicional(c, en, null, s.Linea, s.Columna);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(4 /*sent_if*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 8: // sent ::= error
            {
                Sentencia RESULT = null;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(3 /*sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 7: // sent ::= fuction_call
            {
                Sentencia RESULT = null;
                Sentencia s      = (Sentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;
                RESULT = s;
                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(3 /*sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 6: // sent ::= sent_assign
            {
                Sentencia RESULT = null;
                Sentencia s      = (Sentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;
                RESULT = s;
                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(3 /*sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 5: // sent ::= sent_repeat
            {
                Sentencia RESULT = null;
                Sentencia s      = (Sentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;
                RESULT = s;
                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(3 /*sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 4: // sent ::= sent_if
            {
                Sentencia RESULT = null;
                Sentencia s      = (Sentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;
                RESULT = s;
                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(3 /*sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 3: // secuencia_sent ::= sent
            {
                ListaSentencia RESULT = null;
                Sentencia      s      = (Sentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new ListaSentencia();
                RESULT.agregarElemento(s);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(2 /*secuencia_sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 2: // secuencia_sent ::= secuencia_sent PUNTO_Y_COMA sent
            {
                ListaSentencia RESULT = null;
                ListaSentencia sc     = (ListaSentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 2)).value;
                Sentencia      s      = (Sentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                sc.agregarElemento(s);
                RESULT = sc;

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(2 /*secuencia_sent*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 1: // programa ::= secuencia_sent
            {
                Programa       RESULT = null;
                ListaSentencia sc     = (ListaSentencia)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 0)).value;

                RESULT = new Programa(sc, 1, 0);

                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(1 /*programa*/, RESULT);
            }
                return(CUP_TinyParser_result);

            /*. . . . . . . . . . . . . . . . . . . .*/
            case 0: // $START ::= programa EOF
            {
                object   RESULT    = null;
                Programa start_val = (Programa)((TUVienna.CS_CUP.Runtime.Symbol)CUP_TinyParser_stack.elementAt(CUP_TinyParser_top - 1)).value;
                RESULT = start_val;
                CUP_TinyParser_result = new TUVienna.CS_CUP.Runtime.Symbol(0 /*$START*/, RESULT);
            }
                /* ACCEPT */
                CUP_TinyParser_parser.done_parsing();
                return(CUP_TinyParser_result);

            /* . . . . . .*/
            default:
                throw new System.Exception(
                          "Invalid action number found in internal parse table");
            }
        }