static void Main(string[] args) { try { Console.WriteLine("欢迎来到.net高级班公开课之设计模式特训,今天是Eleven老师为大家带来的建造者模式Builder"); Console.WriteLine("**********************************"); { AbstractBuilder builder = new BuilderFord(); builder.Engine(); builder.Wheels(); builder.Light(); builder.Car(); } Console.WriteLine("**********************************"); { AbstractBuilder builder = new BuilderBYD(); builder.Engine(); builder.Wheels(); builder.Light(); builder.Car(); } Console.WriteLine("**********************************"); { AbstractBuilder builder = new BuilderBYD(); Director director = new Director(builder); director.GetCar(); } Console.WriteLine("**********************************"); { AbstractBuilder builder = new BuilderVolkswagen(); Director director = new Director(builder); director.GetCar(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
static void Main(string[] args) { { AbstractBuilder ford = new BuilderFord(); ford.Engine(); ford.Wheels(); ford.Light(); ford.Car(); AbstractBuilder bmw = new BuilderBMW(); bmw.Engine(); bmw.Wheels(); bmw.Light(); bmw.Car(); } Console.WriteLine("************************升级**************************"); { AbstractBuilder ford2 = new BuilderFord(); Director dir = new Director(ford2); dir.GetCar(); } Console.Read(); }