Question: Create three class Home, Auto and Food . Provide each class with accessor and mutator methods. Provide additional instance variables related to calculating the Carbon
Create three class Home, Auto and Food .
Provide each class with accessor and mutator methods.
Provide additional instance variables related to calculating the Carbon Footprint (CO2 emmission) (See http://www.carbonglobe.com/carbon-footprint-formula.php for formula for each type). Home ClassInstance variables
Catagory of home (Condo, private home, trailer etc)
Type of Fuel (Electric, Gas, Oil)
Average monthly cost
Cost per unit of full so either in per Kilowatt/Hour for electricity, per 1000 cubic feet for gas, or per gallon for oil)
Use type of fuel category field in a method to determine emission factor.
Vehicle ClassInstance variables
Make, model and year of vehicle (each its own instance variable)
Number of miles driven per week
Fuel efficiency in miles per gallon
Food class Instance variables
Name of food
Dollars spent on food
Category of food.
Use the food category field to in an method to determine the emission factor.
Create an Interface called CarbonFootprint with one method getCarbonFootprint that returns a double representing the carbon footprint in pounds.
The three classes,Home, Auto and Food, must implement the CarbonFootprint Inteface.
Create a main application class Reads data from a file that contains the data required to create at least 3 instances of each of our three classes (so at least 9 object total)
The file format is left up to the developer but must be included in the submission.
Since the type and amount of data differ for each category, it may be wise to use the first field on a given line to identity the category.
Create objects based on the data from the file and place those object in an Array/ArrayList of the CarbonFootprint Interface type.
Iterate through the Array/ArrayList calling the getCarbonFootprint method polymorphically and the catagory and type of item such as:
My private home's carbon footprint is 20555.43 lbs per year.
My 2001 Toyota Camry's carbon footprint is 14234.56 lbs per year.
An Apple's carbon footprint is 1238.22 lbs per year.
The remaining design details are left up to the developer, including how to structure the application, how many classes to develop and the interrelationship of those classes. Use the techniques you've learned in this course, including good object oriented design.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
