static void Main(string[] args) { Ishape Ishape = ShapeFactory.getShape(ShapeType.Circle); Ishape.draw(); Console.WriteLine("Hello World!"); }
static void Main(string[] args) { AbstractFactory shapefactory = FactoryProducer.GetFactory("Shape"); Ishape shape1 = shapefactory.GetIshape("Rectangle"); shape1.draw(); Ishape shape2 = shapefactory.GetIshape("Square"); shape2.draw(); AbstractFactory colorfactory = FactoryProducer.GetFactory("Color"); Icolor color1 = colorfactory.GetIcolor("red"); color1.fill(); Icolor color2 = colorfactory.GetIcolor("green"); color2.fill(); //单例 danli newclass = danli.GetDanli(); danli newclass2 = danli.GetDanli(); //建造者模式 Customer customer1 = new Customer(); customer1.BuyComputer(); Console.Read(); }
public static void draw(Ishape a) { Console.WriteLine("Drawing to screenshape: Height={0} width={1}", a.x, a.y); }