Пример #1
0
        public static IShapeBoardBuilder Create(string name, int size)
        {
            RandomizingShapeBuilder builder = new RandomizingShapeBuilder();

            builder.SetName(name);

            Random randomizer = new Random(100);

            for (int index = 0; index < size; index++)
            {
                if (randomizer.Next() % 3 == 0)
                {
                    builder.AddCircle(new Circle {
                        Name = $"Circle {index}"
                    });
                }
                else if (randomizer.Next() % 3 == 1)
                {
                    builder.AddSquare(new Square {
                        Name = $"Square {index}"
                    });
                }
                else
                {
                    builder.AddTriangle(new Triangle {
                        Name = $"Triangle {index}"
                    });
                }
            }

            return(builder);
        }
Пример #2
0
        protected override void DoRun()
        {
            Console.WriteLine("Create the 'Randomizing Demo Board'...");

            //Console.WriteLine("Initializing 'Simple Demo Board' with 50 shapes..."); -- NO LONGER NECESSARY !!!
            IShapeBoardBuilder builder = RandomizingShapeBuilder.Create("Randomizing Demo Board", 50);
            ShapeBoard         board   = builder.GetShapeBoard();

            Console.WriteLine($"Viewing shapes of '{board.Name}'...");
            foreach (Shape shape in board.Shapes)
            {
                Console.WriteLine($"\tViewing shape: {shape.Name}");
            }
        }