I seem to understand what to do for all of them except for "The class must have a constructor that takes a name and age as arguments, and initializes all variables except the address." I don't get why for this one the code is just the two variables and not the others, when it says to initialize all of them except the address? For the other criteria I did initialize all the variables that are listed and it worked but for the name and age one it didn't work with weight and color.
Amber
Level 12
Can someone please explain initializing variable?
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Monica Nicoleta
19 May 2019, 15:53
A constructor can initialize all the variables of its class, if needed, even if the constructor takes only part of those variables as arguments. The only condition is that there has to be a value assigned to the initialized variables that are not taken as arguments by the constructor. I hope it helps.
+1
Khairul
17 May 2019, 12:00
Hi, Amber,
Can you add your code with the problem description. It is hard to explain your problem without seeing the code. Publish your code and notify me. I will see, if I can give you a good explanation.
0
Amber
23 May 2019, 18:28
Hi, I did not add my code because I was able to come up with a solution and move forward, Monica's response is helpful though. Thank you!
0