[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:IN your doPost() method, you don't assign resultat a value after you set it to 0. Remember that Java doesn't update primitives when you pass them as parameters. Which means passing resultat to the constructor isn't helping you.
Yesterday, I wrote:
Apart from the return type, which I think is incorrect, and the missing parts of the switch statement, there is another difference between the two . . . :eek:And later yesterday, you wrote:
There is another thing. You can create an object and call some method calls on it:Note that class names should not be verbs. Calculateur not Calculer please. And remember that method names shouldn't begin with Capital Letters. There are good reasons for those conventions. You have a potential error because your constructor and method have the same name.A few minutes ago, I wrote:. . . Putting a calculer() call in the getResultat() method means that resultat is always updated when it is required. . . .
0.0
2.89373
2.89373
le calcul de : 2+ 4 a pour total : 0.0
So what problems are you having with getXXX and setXXX methods? Your setXXX and getXXX methods in the latest code block look correct, but the calculate method still has the problems I told you about last week not corrected. I would say that setXXX and getXXX methods are basic things, which you should know about before trying JavaEE programming.Philippe Ponceblanc wrote:. . . i take a course of java EE, with videos and an associated tutorial . . . . Now I have problems with getters and setters . . .
Campbell Ritchie wrote:
So what problems are you having with getXXX and setXXX methods? Your setXXX and getXXX methods in the latest code block look correct, but the calculate method still has the problems I told you about last week not corrected. I would say that setXXX and getXXX methods are basic things, which you should know about before trying JavaEE programming.Philippe Ponceblanc wrote:. . . i take a course of java EE, with videos and an associated tutorial . . . . Now I have problems with getters and setters . . .
It would seem that your result is transient and is based on the content of num1, num2, and operand (should be operator). I would do away with your 'resultat' field because it will often be out of date as you call the various setters. Have only one of getResultat() or calculer() (should begin with lower case) that returns the result but does not store it. Your current approach of storing resultat is getting you into trouble. Also you should not have a setResult() method.Philippe Ponceblanc wrote:
All things are lawful, but not all things are profitable.
This is my favorite tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|