Beispiel #1
0
        private static Shape[] GetListOfShapes(int amount)
        {
            Shape[] ret = new Shape[amount];
            for (int i = 0; i < amount; ++i)
            {
                ret[i] = _prototypes[_random.Next(0, 3)];
                RandomizeShape(ret[i]);
            }

            return ret;
        }
Beispiel #2
0
 private static void RandomizeShape(Shape shape)
 {
     if(shape.GetType() == typeof(Triangle))
     {
         ((Triangle)shape).Base = (double)_random.Next(1, 40);
         ((Triangle)shape).Height = (double)_random.Next(1, 40);
     }
     else if (shape.GetType() == typeof(Circle))
     {
         ((Circle)shape).Radius = (double)_random.Next(1, 40);
     }
     else if(shape.GetType() == typeof(Rectangle))
     {
         ((Rectangle)shape).Width = (double)_random.Next(1, 40);
         ((Rectangle)shape).Height = (double)_random.Next(1, 40);
     }
 }