Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 12 results for
carbonfootprint
- Page 1
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Violet_82
… down in classes: INterface: /*
CarbonFootprint
interface. File
CarbonFootprint
.java*/ public interface
CarbonFootprint
{ double getCarbonFootprint();//calculates the carbon …getCarbonFootprint() location: variable categories of type ArrayList<
CarbonFootprint
> 4 errors antobbo@antobbo-xps17-ubuntu:~/Documents/…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by JamesCherrill
…categories is an ArrayList containing only
CarbonFootprint
objects (objects that implement the
CarbonFootprint
interface). So the compiler will…you adding any object that is not a
CarbonFootprint
, and equally knows that any object you …get from that ArrayList wil be a
CarbonFootprint
, and will therefore have the getCarbonFootprint() method.…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Violet_82
… you suggested to have this ArrayList<
CarbonFootprint
> categories = new ArrayList<
CarbonFootprint
>();//creates array of objects of type…^ symbol: method getCarbonFootprint() location: variable categories of type ArrayList<
CarbonFootprint
> 1 error Completely blank, I have no idea. The…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Violet_82
…, in my code only objects of type `
CarbonFootprint
` have the `getCarbonFootprint()` method because it has… been declare inside the interface `
CarbonFootprint
`. That said I don't understand what …quot; Data of each object:\n "); for(
CarbonFootprint
currentObject : categories ){ System.out.printf("%s \…
calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Violet_82
…'t have in common with other classes. Write an interface `
CarbonFootprint
` with a `getCarbonFootprint` method. Have each of your classes implement… 3 classes, places references to those objects in `ArrayLists<
CarbonFootprint
>`, then iterates through the `ArrayLists`, polymorphycally invoking each object…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by JamesCherrill
… a getCarbonFootprint() method. You must get one or more actual
CarbonFootprint
objects from tyhe list, then use it/them to call…
CarbonFootprint
's getCarbonFootprint() method. eg ArrayList<String> strings = ..... strings.…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Violet_82
… name to identify which object I am talking about): for(
CarbonFootprint
currentObject : categories ){ System.out.printf("\n%s: %s \n…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Lucaci Andrew
1. If you think that the problem at hand is not that hard, you can only sketch it and start writing code (for larger projects a deeper analysis is required). 2. Since you have to compute the carbon footprint of each of those objects, and you have the formulas, I'm guessing that you can use as attributs those concepts from the formulas. Still, you …
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by JamesCherrill
Since you don't actually do anything with those classes it doesn't matter what attributes they have, so maybe this example is a bit *too* simple? Do you still have your code for two or more console-based games (tictactoe, hangman, scissors/paper/rock or whatever)?. If so it may be interesting to package those as classes into a simgle games console…
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by Violet_82
JamesCherrill, it would be a really really good idea but unfortunately I only have the tic tac toe and judging from a quick look at my computer I don't think I have developed any other game in java unfortunately. Also if it wasn't for the fact that I have to crack on with the theory I would almost be tempted to attempt one or two more games, but I …
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by JamesCherrill
Lists use methods to add and access elements, not the [] notation. eg `categories.add(new Bike(200.00));` Check the ArrayList API documentation for all the methods you can use.
Re: calculate carbon footprint program
Programming
Software Development
10 Years Ago
by scudzilla
Use categories.get(#) to get individual elements of the arraylist. Use a for each loop to get all elements of the arraylist. Use one or the other, not both (usually, that is). JamesCherrill was just showing you both at the same time just to compare. Anyway, inside your for loop, lines 11 and 12, since you assigned each element of categories to …
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC