private AbstractEngine GetEngineByName(EngineNames name) { switch (name) { case EngineNames.Gasoline: return(new GasolineEngine(2.1, 8.3)); case EngineNames.Diesel: return(new DieselEngine(3, 15)); case EngineNames.Electrical: return(new ElectricalEngine(40)); } throw new ArgumentOutOfRangeException(); }
public static AbstractEngine GetEngine(EngineNames name, double capacity, double consumption) { switch (name) { case EngineNames.Gasoline: return(new GasolineEngine(capacity, consumption)); case EngineNames.Diesel: return(new DieselEngine(capacity, consumption)); case EngineNames.Electrical: return(new ElectricalEngine(consumption)); } throw new ArgumentOutOfRangeException(); }