Exemplo n.º 1
0
        public void DataStructuresGetArea()
        {
            DataStructures.Rectangle rect = new DataStructures.Rectangle
            {
                X = 3,
                Y = 4
            };

            Assert.AreEqual(12, DataStructures.ShapeHelper.GetArea(rect));

            DataStructures.Square sqr = new DataStructures.Square
            {
                Width = 5
            };

            Assert.AreEqual(25, DataStructures.ShapeHelper.GetArea(sqr));

            DataStructures.Triangle tri = new DataStructures.Triangle
            {
                X = 3,
                Y = 4
            };

            Assert.AreEqual(6, DataStructures.ShapeHelper.GetArea(tri));
        }
Exemplo n.º 2
0
 private static double GetTriangleArea(Triangle tri)
 {
     return tri.X * tri.Y / 2.0;
 }