Beispiel #1
0
        /// <summary>
        /// Returns 5-20 random 3d shapes that have sides of 5-100
        /// </summary>
        public static Shape3D[] Randomize3DShapes()
        {
            int numberOfShapes = random.Next(5, 21);
            Shape3D[] shapes = new Shape3D[numberOfShapes];

            for (int i = 0; i < numberOfShapes; i++) {
                Shape3D shape;
                switch (random.Next(3, 6)) {
                    case 3:
                        shape = new Cuboid(random.NextDouble(5, 100), random.NextDouble(5, 100), random.NextDouble(5, 100));
                        break;
                    case 4:
                        shape = new Cylinder(random.NextDouble(5, 50), random.NextDouble(5, 50), random.NextDouble(5, 100));
                        break;
                    case 5:
                        shape = new Sphere(random.NextDouble(5, 50));
                        break;
                    default:
                        shape = null;
                        break;
                }
                shapes[i] = shape;
            }

            return shapes;
        }