static void Main(string[] args) { Console.WriteLine("Hello World!"); var factory = new WebSiteFactory(); WebSite webSite1 = factory.GetWebSiteCategory("新闻"); webSite1.Use(); WebSite webSite2 = factory.GetWebSiteCategory("博客"); webSite2.Use(); WebSite webSite3 = factory.GetWebSiteCategory("博客"); webSite3.Use(); }
static void Main(string[] args) { WebSiteFactory f = new WebSiteFactory(); WebSite fx = f.GetWebSiteCategory("产品展示"); fx.Use(new User("小菜")); WebSite fy = f.GetWebSiteCategory("产品展示"); fy.Use(new User("大鸟")); WebSite fz = f.GetWebSiteCategory("产品展示"); fz.Use(new User("娇娇")); WebSite fl = f.GetWebSiteCategory("博客"); fl.Use(new User("老顽童")); WebSite fm = f.GetWebSiteCategory("博客"); fm.Use(new User("桃谷六仙")); WebSite fn = f.GetWebSiteCategory("博客"); fn.Use(new User("南海神鳄")); Console.WriteLine("得到网站分类总数为{0}", f.GetWebSiteCount()); }
static void Main(string[] args) { WebSiteFactory f = new WebSiteFactory(); WebSite fx = f.GetWebSiteCategory("产品展示"); fx.Use(new User("小菜")); WebSite fy = f.GetWebSiteCategory("产品展示"); fy.Use(new User("大鸟")); WebSite fz = f.GetWebSiteCategory("产品展示"); fz.Use(new User("娇娇")); WebSite fl = f.GetWebSiteCategory("博客"); fl.Use(new User("娜娜")); WebSite fm = f.GetWebSiteCategory("博客"); fm.Use(new User("铁纱杏")); WebSite fn = f.GetWebSiteCategory("博客"); fn.Use(new User("东好学")); Console.WriteLine("网站分类总数为:{0}", f.GetWebSiteCount()); Console.ReadKey(); }
static void Main(string[] args) { WebSiteFactory f = new WebSiteFactory(); WebSite f1 = f.GetWebSiteCategory("产品展示"); f1.Use(new User("诸葛亮")); WebSite f2 = f.GetWebSiteCategory("产品展示"); f2.Use(new User("曹操")); WebSite f3 = f.GetWebSiteCategory("博客"); f3.Use(new User("刘备")); WebSite f4 = f.GetWebSiteCategory("博客"); f4.Use(new User("周瑜")); System.Console.WriteLine($"网站分类总数为{f.GetWebSiteCount()}"); }
static void Main(string[] args) { int extrinsicstate = 22; FlyweightFactory factory = new FlyweightFactory(); Flyweight fx = factory.GetFlyweight("X"); fx.Operation(--extrinsicstate); Flyweight fy = factory.GetFlyweight("Y"); fy.Operation(--extrinsicstate); Flyweight fz = factory.GetFlyweight("Z"); fz.Operation(--extrinsicstate); Flyweight uf = new UnsharedConcreteFlyweight(); uf.Operation(--extrinsicstate); Console.WriteLine(); WebSiteFactory webSiteFactory = new WebSiteFactory(); WebSite wx = webSiteFactory.GetWebSiteCategory("產品展示"); wx.Use(new User("小菜")); WebSite wy = webSiteFactory.GetWebSiteCategory("產品展示"); wy.Use(new User("大鳥")); WebSite wz = webSiteFactory.GetWebSiteCategory("產品展示"); wz.Use(new User("嬌嬌")); WebSite wl = webSiteFactory.GetWebSiteCategory("部落格"); wl.Use(new User("老頭")); WebSite wm = webSiteFactory.GetWebSiteCategory("部落格"); wm.Use(new User("明明")); WebSite wn = webSiteFactory.GetWebSiteCategory("部落格"); wn.Use(new User("寶寶")); Console.WriteLine($"網站分類總數為: {webSiteFactory.GetWebStieCount()}"); Console.ReadLine(); }