Example #1
0
        static void Main(string[] args)
        {
            ICarbonFootprint[] myCarbonFootprint = new ICarbonFootprint[3];

            myCarbonFootprint[0] = new Bicycle();
            myCarbonFootprint[1] = new Building(2500);
            myCarbonFootprint[2] = new Car(15);

            foreach (ICarbonFootprint element in myCarbonFootprint)
            {
                element.CalcCarbonFootprint();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            //create an array of ICarbonFootprint, then initalise it with an objet of each type:

            ICarbonFootprint[] vehicleList = new ICarbonFootprint[3];

            vehicleList[0] = new Building(2000);
            vehicleList[1] = new Car(60);
            vehicleList[2] = new Bicycle();


            foreach (ICarbonFootprint item in vehicleList)
            {
                item.GetCarbonFootPrint();
            }
        }