Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java How to Program, by Deitel, 10th Edition, Chapter 10, Making a Difference 10.17 10.17 ( CarbonFootprint Interface: Polymorphism) Using interfaces, as you learned in

Java How to Program, by Deitel, 10th Edition, Chapter 10, Making a Difference 10.17

10.17 ( CarbonFootprint Interface: Polymorphism) Using interfaces, as you learned in

this chapter, 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 inheritanceclasses Building, Car and Bicycle.

Give each class some unique appropriate attributes and behaviors that it does not have

in common with other classes.

Write an interface CarbonFootprint 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 application that creates objects of each of the three classes, places references

to those objects inArrayList, then iterates through theArrayList,

polymorphically invoking each objects getCarbonFootprint method. For each object,

print some identifying information and the objects carbon footprint.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago