public List <IAutomobile> InputListFromConsole() { List <IAutomobile> automobiles = new List <IAutomobile>(); Console.WriteLine("Enter size of cars(there is a basic list of machines, if you do not want to add to the list " + "enter the size of the cars 0): "); string str = Console.ReadLine(); int count = Convert.ToInt32(str); if (count > 0) { ShowHead(); for (int i = 0; i < count; i++) { string line = Console.ReadLine(); IAutomobile car = Parse(line); automobiles.Add(car); } } else { throw new Exception("wrong size"); } return(automobiles); }
public void Stop() { car_stop = true; IAutomobile self = (IAutomobile)this; // cast this self.Stop(); // forwarding call }
static void Main(string[] args) { AutomobileFactory factory = new AutomobileFactory(); Console.WriteLine("case 1"); IAutomobile audi = factory.make(AutomobileType.Audi); audi.start(); audi.stop(); IAutomobile bmw = factory.make(AutomobileType.BMW); bmw.start(); bmw.stop(); Console.WriteLine("\ncase 2"); IAutomobile unspecified = factory.make(AutomobileType.Unspecified); //unspecified.start(); //unspecified.stop(); Console.WriteLine("\ncase 3"); AutomobileFactory factory1 = new AutomobileFactory(); IAutomobile tesla = factory1.make(AutomobileType.Tesla); tesla.start(); tesla.stop(); }
static void Main(string[] args) { //Case1(); IAutomobile auto = LoadDataFromFile <IAutoFactory>().Make(); auto.start(); Console.ReadKey(); }
public static void AbstractFactoryDemo() { var bmwFactory = new BmwFactory(); IAutomobile myCar = bmwFactory.CreateSportsCar(); myCar.IntroDuce(); Console.WriteLine(myCar.GetType().Name); }
private static void Case1() { IAutoFactory Factory = BMWFactory.GetInstance(); IAutomobile auto = Factory.Make(); auto.start(); auto.stop(); Console.WriteLine(Factory); }
AutoListVM.AutoVM AssembleAutoVM(IAutomobile auto) { return(new AutoListVM.AutoVM() { Id = auto.Id, Model = auto.Model, Name = auto.Name }); }
static void Main(string[] args) { //Case1(); IAutomobile UR = CreateInstance <TeslaFactory>().Make(); UR.Start(); UR.Stop(); Console.ReadKey(); }
static void Main(string[] args) { //Case1(); AutomobileFactory factory = AutomobileFactory.GetInstance(); IAutomobile auto1 = factory.Make(AutoType.AUDI); Console.WriteLine(auto1.GetType()); auto1.Start(); auto1.Stop(); }
public ComplexRule(string String, BreedEnum Breed, int Int, long Long, byte Byte, double Double, bool Bool, IAutomobile car, IAutomobile[] cars) { _String = String; _color = Breed; _Int = Int; _Long = Long; _Byte = Byte; _Double = Double; _Bool = Bool; }
private static IAutomobile[] SetupAutomobiles() { var automobileList = new IAutomobile[] { new SubaruOutback(), new SUV(), new Truck() }; return(automobileList); }
static void Main(string[] args) { AutoMobileFactory factory = AutoMobileFactory.GetInstance(); IAutomobile auto = factory.Make(AutoType.AUDI); auto.Start(); auto.Stop(); Type t = auto.GetType(); Console.WriteLine(t); }
public void Setup() { _subareOutbackMock = new SubaruOutback(); _suvMock = new SUV(); _truckMock = new Truck(); var autoMobiles = new IAutomobile[] { _subareOutbackMock, _suvMock, _truckMock }; _automobileFactory = new AutomobileFactory(autoMobiles); }
static void Main() { IAutoFactory autoFactory = LoadFactory(); //Caller just delegates the pobject creation to a specific factory //which takes the a configuration based approach to decide which factory to return and //which in turn decides which concrete class to return //Here the factory is known but the creation is centralised to specific factory //Also more customized objects can be created. IAutomobile car = autoFactory.CreateSportsCar(); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
static void Main(string[] args) { IKernel kernel = new StandardKernel(new CustomerModule()); // Easy way to create factory. No class created, only interface. IAutomobileFactory factory = kernel.Get <IAutomobileFactory>(); // Instead of NEW keyword IAutomobile instance = factory.CreateAutomobile("Honda", "Civic", 500); IAutomobile instance2 = factory.CreateAutomobile("Honda", "Jazz", 200); Console.WriteLine(instance.Price); Console.WriteLine(instance2.Price); // Inject dependency IInputOutputProvider into IWheaterDataProvider IWeatherDataProvider weather = kernel.Get <IWeatherDataProvider>(); weather.DisplayWeatherInformation("Wonderful wheater"); }
static void Main(string[] args) { AutomobileFactory factory = new AutomobileFactory(); try { IAutomobile bmw = factory.make(AutoType.BMW); bmw.start(); bmw.stop(); IAutomobile audi = factory.make(AutoType.AUDI); audi.start(); audi.stop(); IAutomobile hyundai = factory.make(AutoType.UNSPECIFIED); } catch (UnspecifiedVehicleException e) { Console.WriteLine(e.Message); } Console.Read(); }
static void Main(string[] args) { //IAutomobile auto; //TeslaFactory tesla = TeslaFactory.GetInstance(); //auto = tesla.Make(); //auto.Start(); //auto.Stop(); try { IAutomobile UR = CreateInstance <TeslaFactory>().Make(); UR.Start(); UR.Stop(); Console.ReadKey(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public IAutomobile make(AutomobileType type) { IAutomobile automobile = null; if (type == AutomobileType.Audi) { automobile = new Audi(); } else if (type == AutomobileType.BMW) { automobile = new BMW(); } else if (type == AutomobileType.Tesla) { automobile = new Tesla(); } else { Console.WriteLine("Sorry! there is no car having this name"); return(null); } return(automobile); }
static void Main(string[] args) { try { AutoMobileFactory factory = new AutoMobileFactory(); IAutomobile bmw = factory.Make(Auto.AutoType.BMW); bmw.Start(); bmw.Stop(); IAutomobile audi = factory.Make(Auto.AutoType.AUDI); audi.Start(); audi.Stop(); IAutomobile tesla = factory.Make(Auto.AutoType.TESLA); tesla.Start(); tesla.Stop(); IAutomobile hyundai = factory.Make(Auto.AutoType.UNDEFINED); }catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
public abstract int CompareTo(IAutomobile other);
public AutomobileController(IAutomobile automobile) { this._automobile = automobile; }
public override int CompareTo(IAutomobile other) { return(this.PowerOfEngine.CompareTo(other.PowerOfEngine)); }
private void PerformSafetyChecks(IAutomobile automobile) { Logger.Write($"Performing safety checks for {automobile.Name} in AbstractFactory.UkAutomobileFactory."); }
private void PerformCrashTests(IAutomobile automobile) { Logger.Write($"Performing crash tests for {automobile.Name} in AbstractFactory.UkAutomobileFactory."); }
public ComplexRule(string String, BreedEnum Breed, int Int, long Long, byte Byte, double Double, bool Bool, IAutomobile car, IAutomobile[] cars) { _String = String; _color = Breed; _Int = Int; _Long = Long; _Byte = Byte; _Double = Double; _Bool = Bool; }
public AutomobileController(IAutomobile automobile) { _auto = automobile; }
public IAutomobile FindTheFastest(List <IAutomobile> automobiles) { IAutomobile automobile = automobiles.OrderBy(c => c.MaximumSpeed).Last(); return(automobile); }
public IAutomobile FindEconomical(List <IAutomobile> automobiles, double averageSpeed) { IAutomobile automobile = automobiles.OrderBy(c => c.GetVolumeOfFuel(averageSpeed)).First(); return(automobile); }