David Newton wrote:Well, the logic of the switch statement and if statement are completely different--you're doing entirely different things.
I'm not sure what the array is for, though--why not just return the number of days?
John de Michele wrote:Faiz:
Why not just use an enum for this?
John.
David Newton wrote:At the very least, add the array entries missing--do you see that the values and indices you're using in the two methods are very different?
John de Michele wrote:Faiz:
Well, it's pretty clear that nbVacation should not be an array. At least, not the way you're using it.
John.
Faiz Abdelhafid wrote:
David Newton wrote:At the very least, add the array entries missing--do you see that the values and indices you're using in the two methods are very different?
in my code the number after the case keyword refers to the years of experiences, and the number added to the array is the allowed days off.
I know I am skipping something here :banghead:
Thanks David.
Faiz Abdelhafid wrote:
The idea of the exercise is to use an array as the number of days.
My concern is that if I use the Switch instead of If/If else the code does not work properly.
Joanne
Joanne Neal wrote:
Faiz Abdelhafid wrote:
The idea of the exercise is to use an array as the number of days.
My concern is that if I use the Switch instead of If/If else the code does not work properly.
Were you actually told that you had to initialise your array using an if/else statement or a switch statement ?
Your setVacation method could easily be written as
or not bother with a setVacation method at all and initialise your array when you declare it
SCJP 1.6 96%
Neha Daga wrote:Are you trying to do this:
vacation class:
tester class:
SCJP 1.6 96%
Neha Daga wrote:so, apart from i/o usage is it what you were trying to do? because those 3 lines you can change anyways.
SCJP 1.6 96%
SCJP 1.6 96%
David Newton wrote:@Neha: please be wary of posting full solutions. In general, we really strive not to do that, to allow the person asking the question to develop their own solution. It's almost always more educational that way.
I guess it was not his intention
SCJP 1.6 96%
Neha Daga wrote:
I guess it was not his intention
hey, I am a girl.
SCJP 1.6 96%
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|