Can you please help me by providing me with a step-by-step algorithm as to how to answer the following question
Request:
Can you please help me by providing me with a step-by-step
Question:
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 dispatch. For each object, print a simple message
(e.g., this message from Building CarbonFoot).
Step by step
Solved in 2 steps