示例#1
0
        static void Main(string[] args)
        {
            Triangle tr = new Triangle(1, 2, 3);

            Console.WriteLine("Let triangle sides be: " + tr.ChangeA + ", " + tr.ChangeB + "," + tr.ChangeC);
            Console.WriteLine("Angle between side a and b in this triangle is " + tr.CalculateAngleBetweenAAndB());
            Console.WriteLine("Perimeter of triangle with sides " + tr.ChangeA + ", " + tr.ChangeB + ", " + tr.ChangeC + " is " + tr.Perimeter());
            Console.WriteLine("Let now change value of a = " + tr.ChangeA + " into a = 2");
            tr.ChangeA = 2;

            Console.WriteLine("Now angle between side a and b in this triangle is " + tr.CalculateAngleBetweenAAndB());
            Console.WriteLine("Now perimeter of triangle is " + tr.Perimeter());

            EquilateralTriangle et = new EquilateralTriangle(3);

            Console.WriteLine("Area of the equilateral triangle with side = " + et.ChangeA + " is " + et.CalculateArea());
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            double firstSide  = Double.Parse(textBox1.Text);
            double secondSide = Double.Parse(textBox2.Text);
            double thirdSide  = Double.Parse(textBox3.Text);

            Triangle triangle;

            if (firstSide == secondSide && secondSide == thirdSide)
            {
                triangle = new EquilateralTriangle(firstSide);
            }
            else
            {
                triangle = new Triangle(firstSide, secondSide, thirdSide);
            }

            label2.Text = $"Площа: {triangle.Area}\n\nКут 1: {triangle.FirstAngle}\n\n" +
                          $"Кут 2: {triangle.SecondAngle}\n\nКут 3: {triangle.ThirdAngle}";
        }