Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I need to display the value of 'sum1' after doing some math with it, but i keep getting: "average: gettinganestimate.Average@5f893efe"
someone said it had to do with it being and object and to use a toString method, but that isn't working out too well; I keep getting errors within the method. I had solved the problem for like half a second before, but then i did something and it went away. Any suggestions?
Kirstie Fran wrote:
someone said it had to do with it being and object and to use a toString method, but that isn't working out too well; I keep getting errors within the method. I had solved the problem for like half a second before, but then i did something and it went away. Any suggestions?
It would help if you tell us the details of what you did -- TellTheDetails.
You didn't override the toString() method. The toString() method inherited from the Object class, just states the object class type and the identity hash code.
well one of the suggestions that netbeans gave me was to place "@override" just outside of the toString() Method, but that didn't work out to well for me. So how would i actually go about doing this? because i want the actually average to appear
Kirstie Fran wrote:So how would i actually go about doing this? because i want the actually average to appear
Well, you need to create a valid toString() method. And in that method, you need to return a String object -- which is created from the value contained in the sum1 variable.... For that, take a look at the java.lang.Double class.
What went wrong when yo added @Override? Did you get a "doesn't override" compiler error? That is the whole idea of @Override; if you make a tiny spelling mistake you get a compiler error.
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Free, earth friendly heat - from the CodeRanch trailboss