Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            List <Shape> lShape    = new List <Shape>();
            string       separator = "*";

            separator = separator.PadLeft(33, '*') + separator.PadRight(33, '*');
            List <SimpleNAngel> sAngel = new List <SimpleNAngel>();

            // обычные фигуры
            try
            {
                lShape.Add(new Triangle(4, 10, 12));
                lShape.Add(new Foursquare(3));
                lShape.Add(new Rhombus(10, 30));
                lShape.Add(new Rectangle(5, 11));
                lShape.Add(new Parallelogram(10, 8, 30));
                lShape.Add(new Circle(2));
                lShape.Add(new Ellipse(1, 5));
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                Console.WriteLine(separator);
            }
            // показываем площади обычных фигур
            foreach (Shape sh in lShape)
            {
                sh.Show();
                sh.SquareShape();
                sh.PerimeterShape();
                Console.WriteLine(separator);
            }

            // многоугольники
            try
            {
                sAngel.Add(new SimpleNAngel(10, 6, 10, 3, 8));
                sAngel.Add(new SimpleNAngel(12, 5, 25, 4, 9));
                sAngel.Add(new SimpleNAngel(9, 5, 20, 6, 7));
                sAngel.Add(new SimpleNAngel(9, 4, 20, 6, 7));
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                Console.WriteLine(separator);
            }
            CompositeShape cs = new CompositeShape();

            // показываем площади многоугольников
            foreach (SimpleNAngel sa  in sAngel)
            {
                sa.Show();
                Console.WriteLine("Площадь многоугольника: {0}", sa.SquareShape());
                Console.WriteLine("Периметр многоугольника: {0}", sa.PerimeterShape());
                Console.WriteLine(separator);
                cs.AddSimplePolygon(sa);
            }
            // показываем площади составных фигур
            Console.WriteLine("Площадь составной фигуры: {0}", cs.SquareShape());
            Console.WriteLine("Периметр составной фигуры: {0}", cs.PerimeterShape());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List<Shape> lShape = new List<Shape>();
            string separator = "*";
            separator = separator.PadLeft(33, '*') + separator.PadRight(33, '*');
            List<SimpleNAngel> sAngel = new List<SimpleNAngel>();
            // обычные фигуры
            try
            {
                lShape.Add(new Triangle(4, 10, 12));
                lShape.Add(new Foursquare(3));
                lShape.Add(new Rhombus(10, 30));
                lShape.Add(new Rectangle(5, 11));
                lShape.Add(new Parallelogram(10, 8, 30));
                lShape.Add(new Circle(2));
                lShape.Add(new Ellipse(1, 5));
            }
            catch(Exception err)
            {
                Console.WriteLine(err.Message);
                Console.WriteLine(separator);
            }
            // показываем площади обычных фигур
            foreach(Shape sh in lShape)
            {
                sh.Show();
                sh.SquareShape();
                sh.PerimeterShape();
                Console.WriteLine(separator);
            }

            // многоугольники
            try
            {
                sAngel.Add(new SimpleNAngel(10, 6, 10, 3, 8));
                sAngel.Add(new SimpleNAngel(12, 5, 25, 4, 9));
                sAngel.Add(new SimpleNAngel(9, 5, 20, 6, 7));
                sAngel.Add(new SimpleNAngel(9, 4, 20, 6, 7));
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                Console.WriteLine(separator);
            }
            CompositeShape cs = new CompositeShape();
            // показываем площади многоугольников
            foreach (SimpleNAngel sa  in sAngel)
            {
                sa.Show();
                Console.WriteLine("Площадь многоугольника: {0}", sa.SquareShape());
                Console.WriteLine("Периметр многоугольника: {0}", sa.PerimeterShape());
                Console.WriteLine(separator);
                cs.AddSimplePolygon(sa);
            }
            // показываем площади составных фигур
            Console.WriteLine("Площадь составной фигуры: {0}", cs.SquareShape());
            Console.WriteLine("Периметр составной фигуры: {0}", cs.PerimeterShape());
        }