Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Create three small classes unrelated by inheritanceclasses Building, Car and Bicycle. Write an interface CarbonFootprint with a getCarbonFootprint method. Have each of your classes

JAVA Create three small classes unrelated by inheritanceclasses 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 calculates an appropriate carbon footprint for that class. Each class should have a constructor that requires the data needed to calculate the carbon footprint. Write an application that creates objects of each of the three classes, places references to those objects in an array of type CarbonFootpint then iterates through the array 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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions