コード例 #1
0
ファイル: ShapesMain.cs プロジェクト: DiyanTonchev/SoftUni
        static void Main()
        {
            var circle    = new Circle(10.5);
            var rectangle = new Rectanlge(4.5, 5.4);
            var triangle  = new Triangle(5, 6, 4, 5);

            var shapes = new List <IShape>()
            {
                circle,
                rectangle,
                triangle
            };

            foreach (var shape in shapes)
            {
                Console.WriteLine("{0} -> Area: {1:F4}; Perimeter: {2:F4};",
                                  shape.GetType().Name, shape.CalculateArea(), shape.CalculatePerimeter());
            }
        }
コード例 #2
0
ファイル: ShapesMain.cs プロジェクト: alvelchev/SoftUni
        static void Main()
        {
            var circle = new Circle(10.5);
            var rectangle = new Rectanlge(4.5, 5.4);
            var triangle = new Triangle(5, 6, 4, 5);

            var shapes = new List<IShape>()
            {
                circle,
                rectangle,
                triangle
            };

            foreach (var shape in shapes)
            {
                Console.WriteLine("{0} -> Area: {1:F4}; Perimeter: {2:F4};",
                    shape.GetType().Name, shape.CalculateArea(), shape.CalculatePerimeter());
            }
        }