Initializing cats

  • 8
  • Locked
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.
You can't complete this task, because you're not signed in.
Comments (28)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
furius72
Level 9 , Milan, Italy
28 October 2022, 09:28
if you declar first initialize "black" into other initialize is always "black". i hope was util you
Hemel
Level 7 , London, United Kingdom
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.
Toni Fields
Level 12 , Jacksonville, United States
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.
kar-fai chow
Level 8 , Hong Kong, Hong Kong
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
Nutty Coder
Level 8 , United States
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. đŸ€Ș
Youngsan
Level 41 , Seoul, Korea, Republic of
28 August 2020, 11:42
Resolved, but I don't understand the answers. Only initialize age and weight with the specified arguments.
Ashleigh
Level 7 , Easton, United States
30 July 2020, 01:42
Why does the 3rd initialize method
The class must have an initialize method that takes a name and age as arguments, and initializes all variables except the address.
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?
Lucas Hoage
Level 14 , Savannah, United States
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
Ɓukasz
Level 16 , GDANSK, POLAND
14 May 2020, 10:18
First time I made 10 unsuccessful attempts resolve problem :) very unclear task content. P.S. thx BlueJavaBanana
Devonte A
Level 18 , Rubery, United Kingdom
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";