示例#1
0
文件: Program.cs 项目: jonwa/CSharp
 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);
     }
 }