Ejemplo n.º 1
0
        protected void CalculateTriangle(object sender, EventArgs e)
        {
            TypeOfTriangle.Text = "";
            Area.Text           = "";
            var         x           = Convert.ToInt32(FirstSide.Text);
            var         y           = Convert.ToInt32(SecondSide.Text);
            var         z           = Convert.ToInt32(ThirdSide.Text);
            Scalene     scalene     = new Scalene();
            Isosceles   isosceles   = new Isosceles();
            Equilateral equilateral = new Equilateral();

            var abs = System.Math.Abs(x - y);   // absolute value of substruction

            //third point's value must be with in the range of difference of the other sides to the total of the other sides,
            if (!(z > abs && z < x + y))
            {
                TypeOfTriangle.Text     = "These are not valid values to draw a triangle!";
                CalculateButton.Enabled = false;
            }
            else
            {
                TypeOfTriangle.Text     = "Triangle is valid.";
                CalculateButton.Enabled = true;
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     t = new Isosceles(a2, angle2);
     if (a2 > 0 && angle2 > 0 && angle2 < 180)
     {
         textBox10.Text = Convert.ToString(t.Area());
         textBox9.Text  = Convert.ToString(t.Perimeter());
     }
     else
     {
         textBox10.Text = "Нет данных";
         textBox9.Text  = "Нет данных";
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Triangulo t;

            t = new Escaleno();
            t.a = 3;
            t.b = 4;
            t.c = 5;

            Console.WriteLine(t);

            t = new Isosceles();
            t.a = t.b = 2;
            t.c = 1;

            Console.WriteLine(t);

            t = new Equilatero();
            t.a = t.b = t.c = 1;

            Console.WriteLine(t);

            Console.ReadKey();
        }