Write an app that creates objects of each of the three


(CarbonFootprint Interface: Polymorphism) Using interfaces, as you learned in Chapter 12, you can specify similar behaviors for possibly disparate classes.

Governments and companies worldwide are becoming increasingly concerned with carbon footprints (annual releases of carbon dioxide into the atmosphere) from buildings burning various types of fuels for heat, vehicles burning fuels for power, and the like. Many scientists blame these greenhouse gases for the phenomenon called global warming.

Create three small classes unrelated by inheritance - classes Building, Car, and Bicycle. Write an interface ICarbonFootprint with a GetCarbonFootprint method. Have each of your classes implement that interface, so that its GetCarbonFootprint method calculates an appropriate carbon footprint for that class (check out a few websites that explain how to calculate carbon footprints).

Write an app that creates objects of each of the three classes, places references to those objects in List, then iterates through the List, polymorphically invoking each object's GetCarbonFootprint method.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write an app that creates objects of each of the three
Reference No:- TGS02383215

Now Priced at $15 (50% Discount)

Recommended (93%)

Rated (4.5/5)