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. Draw a UML diagram and give each class some unique appropriate attributes and behaviors that it does not have in common with other classes. Write an interface releaseCarbonFootprint 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 (surf the web and find out how to calculate different carbon footprints). For Building: (Add Carbon footprints in the result of Natural Gas and Electricity consumption) Due to Natural Gas Consumption : Value of therms of natural gas the building consumes, multiply by a emission factor of 11.7 Due to Electricity Consumption: Carbon foot print (in kg)= [consumption of energy] x emission factor = Latest emission factor for electricity consumption is 0.82 For Car: For Diesel: Fuel Consumption per Km in Litre x 2640 g/l / 100 For Petrol: Fuel Consumption per Km in Litre x 2392 g/l / 100 For LPG: Fuel Consumption per Km in Litre x 1665 g/l / 100 (per km) For High Calorific CNG: Fuel Consumption per Km in Kg x 2252/100 For Low Calorific CNG:Fuel Consumption per Km in Kg x 2666/ 100 On average 271g of CO2 is released per KM Bicycles do not require fuel in the same sense of cars and buses, so the ride does not release any more carbon emissions. Food intake, and the energy which it produces to help a cyclist propel their bike, is the final piece of a bike commute carbon footprint. Cyclists on the average diet will add 16 g of CO2 per km ridden. Write an application that creates objects of each of the three classes, places references to those objects in ArrayList, then iterates through the ArrayList, polymorphically invoking each object’s getCarbonFootprint() method. For each object, print some identifying information and the object’s carbon footprint.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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.
Draw a UML diagram and give each class some unique appropriate attributes and behaviors that
it does not have in common with other classes.
Write an interface releaseCarbonFootprint 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 (surf the web and find out how to calculate different
carbon footprints).
For Building: (Add Carbon footprints in the result of Natural Gas and Electricity consumption)
Due to Natural Gas Consumption :
Value of therms of natural gas the building consumes, multiply by a emission factor of 11.7
Due to Electricity Consumption:
Carbon foot print (in kg)= [consumption of energy] x emission factor =
Latest emission factor for electricity consumption is 0.82
For Car:
For Diesel: Fuel Consumption per Km in Litre x 2640 g/l / 100
For Petrol: Fuel Consumption per Km in Litre x 2392 g/l / 100
For LPG: Fuel Consumption per Km in Litre x 1665 g/l / 100 (per km)
For High Calorific CNG: Fuel Consumption per Km in Kg x 2252/100
For Low Calorific CNG:Fuel Consumption per Km in Kg x 2666/ 100
On average 271g of CO2 is released per KM
Bicycles do not require fuel in the same sense of cars and buses, so the ride does not release any
more carbon emissions. Food intake, and the energy which it produces to help a cyclist propel
their bike, is the final piece of a bike commute carbon footprint.
Cyclists on the average diet will add 16 g of CO2 per km ridden.
Write an application that creates objects of each of the three classes, places references to those
objects in ArrayList, then iterates through the ArrayList, polymorphically invoking each object’s
getCarbonFootprint() method. For each object, print some identifying information and the
object’s carbon footprint.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)