This task is dedicated to the mysterious and beautiful creatures we call cats. Create a Cat class and define five initializers (only name; name plus weight and age; only weight and color; name and age; weight, color, and address). We need valid cats: they can't exist without a weight and age. Alas, there are cats without names and homes.
Initializing cats
- 8
Locked
Comments (28)
- Popular
- New
- Old
You must be signed in to leave a comment
furius72
28 October 2022, 09:28
if you declar first initialize "black" into other initialize is always "black". i hope was util you
0
Hemel
23 June 2021, 10:28
For anyone that was confused by the wording around "average" they aren't expecting you to calculate any averages. They are simply asking you to make up values for those unknowns.
0
Toni Fields
24 January 2021, 03:24
Make sure that you have the arguments in the same order that they state. On the initialize method that uses name, weight, and age as arguments. I put the arguments in the order of name, age, and weight, and it wouldn't accept it.
0
kar-fai chow
18 November 2020, 05:25
so i named my methods "initialization" rather than "initialize" and cost me 15min and 5 trys.
This requirement is not clear at all. Initialize method can be refer to both these types of method as well as narrowly defined as the name of this particular method
0
Nutty Coder
30 September 2020, 12:58
Perhaps I am over-thinking. But a value like -1 should be an acceptable default for age and weight default. It's more clear some average weight we make up. Same with not being able to use null for a color. Null, like -1, is a clear indicator that we need to have a valid value in there at some point. đ€Ș
0
Youngsan
28 August 2020, 11:42
Resolved, but I don't understand the answers. Only initialize age and weight with the specified arguments.
0
Ashleigh
30 July 2020, 01:42
Why does the 3rd initialize method
Pass without setting values to weight and color yet all the other initialize method variables have to be set if not passed as an argument? 0
Lucas Hoage
27 May 2020, 00:08
For those that are having trouble, remember how we worked with constructors? We used those to auto populate (non) static variables of each object.
Well, when we declared variables that were not part of the constructor and those variables were declared non static within the same class, can you object.variable and the IDE can find that variable? If so, then you know how to complete this task.
By the way, if a variable is null, it is the same as never having "assigned a value (initialized)"
Good luck
0
Ćukasz
14 May 2020, 10:18
First time I made 10 unsuccessful attempts resolve problem :) very unclear task content.
P.S. thx BlueJavaBanana
+2
Devonte A
12 May 2020, 15:51
Set all variables that are not passed into the method but need to be initialized with a random value. e.g. String color = "Blue";
0