public static void CreateAHondaCar() { HondaCar hondacar = new HondaCar("tvs50", 2010); //bad.. because we are letting the user to create any model. HondaCar hondaCivic = HondaCompany.ManufactureCivic(); // good way, because the user is not allowed to meddle with the properties. string makeOfHondaCivic = hondaCivic.GetMake(); //this returns honda civic. there is no way you can modify it. List<HondaCar> hondaCivics = HondaCompany.ManufactureCivic(1000000); /* generate a million cars */ }
public static HondaCar ManufactureCivicHybrid() { HondaCar hondaCivicHybrid = new HondaCar("Civic", 2013); hondaCivicHybrid.engineType = EngineType.Hybrid; return hondaCivicHybrid; }
public static List<HondaCar> ManufactureCivic(int NumberOfCars) { List<HondaCar> civics = new List<HondaCar>(); for (int i = 0; i < NumberOfCars; i++) { HondaCar hondaCivic = new HondaCar("Civic", 2013); hondaCivic.engineType = EngineType.Mechanical; civics.Add(hondaCivic); } return civics; }
public static HondaCar ManufactureCivic() { HondaCar hondaCivic = new HondaCar("Civic", 2013); hondaCivic.engineType = EngineType.Mechanical; return hondaCivic; }