예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            double firstSide  = Double.Parse(textBox1.Text);
            double secondSide = Double.Parse(textBox2.Text);
            double angle      = Double.Parse(textBox3.Text);

            Triangle triangle;

            if (radioButton1.Checked)
            {
                triangle = new RightTriangle(firstSide, secondSide, angle);
            }
            else if (radioButton2.Checked)
            {
                triangle = new IsoscelesTriangle(firstSide, secondSide, angle);
            }
            else
            {
                MessageBox.Show("Оберiть тип трикутника.");
                return;
            }

            label3.Visible = true;
            label3.Text    = $"Площа: {triangle.GetArea()}";
            label4.Visible = true;
            label4.Text    = $"Периметр: {triangle.GetPerimeter()}";
        }
예제 #2
0
        public void RightTriangleIsOK()
        {
            Triangle t = new RightTriangle(3, 4, 5);

            var expectedResult = 6;
            var actualResult = t.GetArea();

            Assert.AreEqual(expectedResult, actualResult);
        }
        public void SerializeAndDeserialize_RightTriangle_Success()
        {
            RightTriangle triangle1 = new RightTriangle(3, 4, 5);

            //Serialize rightTriangle to rightTriangleBytes
            byte[] rightTriangleBytes;
            BinaryFormatter bf1 = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream())
            {
                bf1.Serialize(ms, triangle1);
                rightTriangleBytes = ms.ToArray();
            }

            //Deserialize rightTriangleBytes to rightTriangle
            RightTriangle rightTriangle2;
            BinaryFormatter bf2 = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream(rightTriangleBytes, 0, rightTriangleBytes.Length))
            {
                rightTriangle2 = (RightTriangle)bf2.Deserialize(ms);
            }

            Assert.That(triangle1.Equals(rightTriangle2));
        }
예제 #4
0
 public void IsNotRightTriangle()
 {
     Triangle t = new RightTriangle(3, 4, 6);
     var res = t.GetArea();
 }