Beispiel #1
0
        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 */
        }
Beispiel #2
0
 public static HondaCar ManufactureCivicHybrid()
 {
     HondaCar hondaCivicHybrid = new HondaCar("Civic", 2013);
     hondaCivicHybrid.engineType = EngineType.Hybrid;
     return hondaCivicHybrid;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 public static HondaCar ManufactureCivic()
 {
     HondaCar hondaCivic = new HondaCar("Civic", 2013);
     hondaCivic.engineType = EngineType.Mechanical;
     return hondaCivic;
 }