static void Main(string[] args) { Random r = new Random(Guid.NewGuid().GetHashCode()); double totalArea = 0.0; int kind; ShapeFactory shapeFactory = new ShapeFactory(); for (int i = 0; i < 10; i++) { kind = r.Next(0, 3); double [] arr = InputShapeInfo(kind); totalArea += shapeFactory.GetShape(kind, arr).CalculateArea(); } Console.WriteLine("面积总和为:" + totalArea); }
static void Main(string[] args) { ShapeFactory fac = new ShapeFactory(); S hape shape1 = fac.GetShape("Square"); }