Example #1
0
        private void btnCalcularAyP_Click(object sender, EventArgs e)
        {
            ClaseBase cd = new ClaseBase(Convert.ToDouble(txtLado.Text));

            cd.SetPerimetro(cd.GetLado1() * 4);
            txtPerimetroCuadr.Text = Convert.ToString(cd.GetPerimetro());
            cd.SetArea(cd.GetLado1() * cd.GetLado1());

            txtAreaCuadr.Text = Convert.ToString(cd.GetArea());
        }
Example #2
0
        private void btnCalcularRect_Click(object sender, EventArgs e)
        {
            ClaseBase cl = new ClaseBase(Convert.ToDouble(txtLadoRct.Text),
                                         Convert.ToDouble(txtAnchoRect.Text));

            cl.SetPerimetro(cl.GetLado1() * 2 + cl.GetLado2() * 2);
            txtPerimetroRect.Text = Convert.ToString(cl.GetPerimetro());

            cl.SetArea(cl.GetLado1() * cl.GetLado2());
            txtAreaRect.Text = Convert.ToString(cl.GetArea());
        }
Example #3
0
        private void btnCalcularTrap_Click(object sender, EventArgs e)
        {
            ClaseBase cp = new ClaseBase(Convert.ToDouble(txtBaseMenor.Text),
                                         Convert.ToDouble(txtBaseMayor.Text),
                                         Convert.ToDouble(txtLadoTrap.Text));

            cp.SetPerimetro(cp.GetLado2() + cp.GetLado1() + cp.GetLado3() * 2);
            txtPerimetroTrap.Text = Convert.ToString(cp.GetPerimetro());
            double dif = (cp.GetLado2() - cp.GetLado1()) / 2;
            double h   = Math.Sqrt(Math.Pow(cp.GetLado3(), 2) + Math.Pow(dif, 2));

            cp.SetArea(((cp.GetLado2() + cp.GetLado1()) * h) / 2);
            txtAreaTrap.Text = Convert.ToString(cp.GetArea());
        }
Example #4
0
 private void btnCalcular_Click(object sender, EventArgs e)
 {
     if (!(txtLadoA.Text == "" || txtLadoB.Text == "" || txtLadoC.Text == ""))
     {
         double    a  = Convert.ToDouble(txtLadoA.Text);
         double    b  = Convert.ToDouble(txtLadoB.Text);
         double    c  = Convert.ToDouble(txtLadoC.Text);
         ClaseBase cl = new ClaseBase(a, b, c);
         cl.SetPerimetro(cl.GetLado1() + cl.GetLado2() + cl.GetLado3());
         String re = Convert.ToString(cl.GetPerimetro());
         txtPerimetro.Text = re;
         double semiperimetro = 0;
         semiperimetro = cl.GetPerimetro() / 2;
         //CALCULO AREA CON LA FROMULA DE HERON
         cl.SetArea(Math.Sqrt(semiperimetro * (semiperimetro - a) * (semiperimetro - b) * (semiperimetro - c)));
         txtArea.Text = Convert.ToString(cl.GetArea());
     }
     else
     {
         MessageBox.Show("No hay datos", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
 }