public FactoryMethod_08() { IFactory factory = new UndergraduateFactory(); LeiFeng stu = factory.CreateLeiFeng(); stu.BuyRice(); stu.Wash(); stu.Sweep(); factory = new VolumnteerFactory(); stu = factory.CreateLeiFeng(); stu.BuyRice(); stu.Wash(); stu.Sweep(); }
public static LeiFeng CreateLeiFang(string type) { LeiFeng result = null; switch (type) { case "a": result = new Undergrated(); break; case "b": result = new Volunteer(); break; } return(result); }