Beispiel #1
0
        static void Main(string[] args)
        {
            Figure[] figures = new Figure[5];
            for (int i = 0; i < figures.Length; i++)
            {
                switch (random.Next(4))
                {
                case 0:
                    figures[i] = new Round(RandomPoint(), RandomRadius());
                    break;

                case 1:
                    figures[i] = new Ring(RandomPoint(), RandomRadius(), RandomInnerRadius());
                    break;

                case 2:
                    figures[i] = new Rectangle(RandomPoint(), RandomPoint());
                    break;

                case 3:
                    figures[i] = new Line(RandomPoint(), RandomPoint());
                    break;
                }
            }
            ConsoleCanvas consoleCanvas = new ConsoleCanvas();

            for (int i = 0; i < figures.Length; i++)
            {
                figures[i].Draw(consoleCanvas);
            }
            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ICanvas canvas = new ConsoleCanvas();
            //Circle circle1 = new Circle(5);
            Ring circle1 = new Ring(5, 3);

            circle1.Draw(canvas);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            IFigure[] figure = new IFigure[4];
            figure[0] = new Line(RandomPoint(), RandomPoint());
            figure[1] = new Rect(RandomPoint(), RandomPoint());
            figure[2] = new Round(RandomPoint(), 3);
            figure[3] = new Ring(RandomPoint(), 7, 5);
            ICanvas console = new ConsoleCanvas();

            for (int i = 0; i < figure.Length; i++)
            {
                Console.WriteLine(figure[i].Name);
                figure[i].Draw(console);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Figure[] my = new Figure[4];
            Point    p1 = new Point(3, 5);
            Point    p2 = new Point(6, 9);

            my[0] = new Circle(p1, 4);
            my[1] = new Line(p1, p2);
            my[2] = new FigureLibrary.Rectangle(p1, p2);
            my[3] = new Ring(p2, 7, 2);
            ConsoleCanvas can = new ConsoleCanvas();

            for (int i = 0; i < 4; i++)
            {
                my[i].Draw(can);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            ICanvas canvas = new ConsoleCanvas();

            IFigure[] fig  = new IFigure[10];
            Random    rand = new Random();

            for (int i = 0; i < fig.Length; i++)
            {
                Point randomPosition = new Point(rand.NextDouble() * 100.0, rand.NextDouble() * 100.0);
                switch (rand.Next(4))
                {
                case 0:
                    fig[i] = new Rectangle(randomPosition, 5.0, 5.0);
                    break;

                case 1:
                    fig[i] = new Round(randomPosition, rand.NextDouble() * 100.0);
                    break;

                case 2:
                    fig[i] = new Ring(randomPosition, 20.0, 10.0);
                    break;

                case 3:
                    fig[i] = new Line(randomPosition, randomPosition);
                    break;

                default:
                    break;
                }
            }

            foreach (IFigure figure in fig)
            {
                figure.Draw(canvas);
            }
            Console.ReadKey();
        }