CarbonFootprint Interface Solved

25.00 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (2 votes)

CarbonFootprint Interface: Polymorphism Using interfaces, 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 CarbonFootprint with a getCarbonFootprint method. Have each of your classes implement that interface, so that its getCarbonFootprint method prints out an appropriate message (e.g., this message from Building CarbonFoot).Write an application that creates objects of each of the three classes and one interface reference variable, assign each object to the interface reference variable, and then invoke each object’s getCarbonFootprint method by means of dynamic method resolution. For each object, print a simple message (e.g., this message from Building CarbonFoot= 123… something).