示例#1
0
        static void Main()
        {
            var rhombus   = new Rhombus(4, 5, 4);
            var rectangle = new Rectangle(16, 3);
            var circle    = new Circle(3);

            IShape[] shapes = { rhombus, rectangle, circle };

            foreach (var shape in shapes)
            {
                Console.WriteLine(shape);
            }
        }
示例#2
0
        static void Main()
        {
            Circle    circle    = new Circle(3);
            Rectangle rectangle = new Rectangle(2, 4);
            Rhombus   rhombus   = new Rhombus(1, 3);

            IShape[] figures = new IShape[3] {
                circle, rectangle, rhombus
            };

            foreach (var figure in figures)
            {
                Console.WriteLine(figure.CalculateArea());
            }
        }
示例#3
0
        static void Main()
        {
            Circle    circle    = new Circle(2.50);
            Rectangle rectangle = new Rectangle(5, 3);
            Rhombus   rhombus   = new Rhombus(6, 7);

            IShape[] shapes = new IShape[]
            {
                circle,
                rectangle,
                rhombus
            };

            foreach (var print in shapes)
            {
                Console.WriteLine(print);
            }
        }
示例#4
0
        static void Main()
        {
            Rectangle first  = new Rectangle(5, 4);
            Rectangle third  = new Rectangle(4.5, 6);
            Rhombus   second = new Rhombus(4.4, 2);
            Rhombus   fourth = new Rhombus(7, 0.5);
            Circle    fifth  = new Circle(5);
            Circle    sixth  = new Circle(3.4);

            List <IShape> shapes = new List <IShape>()
            {
                first, second, third, fourth, fifth, sixth
            };

            foreach (var shape in shapes)
            {
                Console.WriteLine("Area of the {0} is: {1:F2}", shape.GetType().Name, shape.CalculateArea());
                Console.WriteLine("Perimeter of the {0} is: {1:F2}\n{2}", shape.GetType().Name, shape.CalculatePerimeter(), new string('-', 13));
            }
        }
示例#5
0
        static void Main()
        {
            Rectangle  firstRectangle  = new Rectangle(4.5, 7.3);
            Circle     firstCircle     = new Circle(4);
            Rhombus    firstRhombus    = new Rhombus(5.2, 3.75);
            BasicShape secondRectangle = new Rectangle(12, 3.1);
            BasicShape secondRhombus   = new Rhombus(8, 3.1);
            Circle     seocndCircle    = new Circle(3.5);

            IShape[] shapes =
            {
                firstRectangle,
                firstCircle,
                firstRhombus,
                secondRectangle,
                secondRhombus,
                seocndCircle
            };

            foreach (var shape in shapes)
            {
                Console.WriteLine("Figure: " + shape.GetType().Name + " Area= " + shape.CalculateArea() + " Perimeter= " + shape.CalucaltePerimeter());
            }
        }