static void Main(string[] args) { var vehicleCreator1 = new VehicleCreator(new HeroBuilder()); vehicleCreator1.CreateVehicle(); var vehicle1 = vehicleCreator1.GetVehicle(); vehicle1.ShowInfo(); Console.WriteLine("--------------------------------------"); var vehicleCreator2 = new VehicleCreator(new HondaBuilder()); vehicleCreator2.CreateVehicle(); var vehicle2 = vehicleCreator2.GetVehicle(); vehicle2.ShowInfo(); Console.WriteLine("--------------------------------------"); var vehicleCreator3 = new VehicleCreator(new DaciaBuilder()); vehicleCreator3.CreateVehicle(); var vehicle3 = vehicleCreator3.GetVehicle(); vehicle3.ShowInfo(); Console.ReadLine(); }
static void Main(string[] args) { // Using HondaBuilder VehicleCreator director = new VehicleCreator(new HondaBuilder()); director.CreateVehicle(); // Getting vehicle information of HondaBuilder var vehicle = director.GetVehicle(); vehicle.ShowInfo(); Console.WriteLine("---------------------------------------------"); // Using Hero Builder director = new VehicleCreator(new HeroBuilder()); director.CreateVehicle(); director.GetVehicle(); // Getting vehicle information of HeroBuilder vehicle = director.GetVehicle(); vehicle.ShowInfo(); }
static void Main() { var vehicleCreator = new VehicleCreator(new HeroBuilder()); vehicleCreator.CreateVehicle(); var vehicle = vehicleCreator.GetVehicle(); vehicle.ShowInfo(); Console.WriteLine("---------------------------------------------"); vehicleCreator = new VehicleCreator(new HondaBuilder()); vehicleCreator.CreateVehicle(); vehicle = vehicleCreator.GetVehicle(); vehicle.ShowInfo(); }
static void Main(string[] args) { var vehicleCreator = new VehicleCreator(new HondaBuilder()); vehicleCreator.CreateVehicle(); var vehicle = vehicleCreator.GetVehicle(); vehicle.ShowVehicleInfo(); Console.WriteLine("---------------"); vehicleCreator = new VehicleCreator(new ToyotaBuilder()); vehicleCreator.CreateVehicle(); vehicle = vehicleCreator.GetVehicle(); vehicle.ShowVehicleInfo(); Console.ReadLine(); }
static void Main(string[] args) { VehicleCreator vehicleCreator = null; //we can use var instead of dynamic...var cannot be initialized to null //However, var will let you figure out mistakes during compile time //Need to be careful with Typos while using dynamic dynamic car = null; //////////////////////////////////////////// Console.WriteLine("//////////////////SwiftLowEnd//////////////////////////"); vehicleCreator = new VehicleCreator(new SwiftLowEnd()); vehicleCreator.GetFunctions(); IVehicle swiftLowEnd = vehicleCreator.GetVehicle(); car = (SwiftLowEnd)swiftLowEnd; //public properties Console.WriteLine(car.ToString());//Overrided ToString() Console.WriteLine("\nAvailbale models: {0}", car.AvailableModel); Console.WriteLine("///////////////////////////////////////////////////////\n\n"); //////////////////////////////////////////// //////////////////////////////////////////// Console.WriteLine("//////////////////SwiftMidVariant///////////////////////"); vehicleCreator = new VehicleCreator(new SwiftMidVariant()); vehicleCreator.GetFunctions(); IVehicle swiftMidVariant = vehicleCreator.GetVehicle(); car = (SwiftMidVariant)swiftMidVariant; //public properties Console.WriteLine(car.ToString());//Overrided ToString() Console.WriteLine("\nAvailbale models: {0}", car.AvailableModel); Console.WriteLine("///////////////////////////////////////////////////////\n\n"); //////////////////////////////////////////// //////////////////////////////////////////// Console.WriteLine("///////////////////SwiftHighEnd////////////////////////"); List <string> availableModels = new List <string> { "Petrol", "Diesel", "Hybrid - Petrol + CNG" }; vehicleCreator = new VehicleCreator(new SwiftHighEnd(availableModels)); vehicleCreator.GetFunctions(); IVehicle swiftHighEnd = vehicleCreator.GetVehicle(); car = (SwiftHighEnd)swiftHighEnd; //public properties Console.WriteLine(car.ToString());//Overrided ToString() Console.WriteLine("\nAvailbale models:"); foreach (string model in car.AvailableModels) { Console.WriteLine(model); } //SwiftHighEnd special ones Console.WriteLine("\nSpecial functions:"); car.BackViperWorking(); car.BluetoothWorking(); car.SteeringMountedControlsWorking(); Console.WriteLine("///////////////////////////////////////////////////////\n\n"); //////////////////////////////////////////// //////////////////////////////////////////// Console.WriteLine("///////////////////FordMustangGT////////////////////////"); vehicleCreator = new VehicleCreator(new FordMustangGT()); vehicleCreator.GetFunctions(); IVehicle fordMustangGT = vehicleCreator.GetVehicle(); car = (FordMustangGT)fordMustangGT; //public properties Console.WriteLine(car.ToString());//Overrided ToString() //FordMustangGT special ones Console.WriteLine("\nSpecial functions:"); car.NitrousOxideWorking(); Console.WriteLine("///////////////////////////////////////////////////////\n\n"); //////////////////////////////////////////// //Just to stop the console Console.ReadLine(); }