Pets need people

  • 3
  • Locked
"You become responsible forever for what you've tamed," said Antoine de Saint-Exupery through the mouth of the Little Prince's fox friend. Let's clean up our program and not leave any animal without a caregiver. We'll create a cat, a dog, and a fish. And a woman. And then we'll assign her as the owner of the fish, dog, and cat. We think she'll like this!
You can't complete this task, because you're not signed in.
Comments (43)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 6 , Spain
14 March, 17:24
Me estaba volviendo loco, solo tenía una variable mal escrita. Ojo con los errores .😋
Level 4
21 December 2022, 15:56
It was pretty easy for me! I just remembered previous lessons. It's exactly what they taught. 😁
Level 2 , United States of America
27 June 2022, 15:58
completed it by trial and error and the hints in the comments. I feel that I am missing some base knowledge in my mental model of variable declaration/initialization/connection. Otherwise it would have been apparent. It is possible it is knowledge gained through repetition. Which I hope it is otherwise will be a weakness in the future. :(
Level 4
21 December 2022, 15:57
Try reviewing previous lessons.
Jeff Kenney
Level 3 , United States
3 December 2021, 05:39
Okay, I got it. It took me a couples of tries, but when I figured it out, it's actually pretty simple. Hint: You can name each animal object whatever you want AS LONG AS the "Woman" object is listed FIRST 😉👍 Example: Cat fuzzy = new Cat(); fuzzy.owner = ownername; OR Cat.whiskers = new Cat(); whiskers.owner = ownername; See the pattern? 😉👌 Hint 2: Woman object only needs a name. Example: Woman beth = new Woman(); OR Woman sarah = new Woman();
Anonymous #10829459
Level 2 , Spain
15 October 2021, 15:46
lo primero es poner los objetos despues dejas espacio y debajo de todos los objetos poner las variables.. las tipo el perro es de la woman o dog.owner=woman... ojala les sirva yo me rompi el cerebro
Level 4 , Santa Cruz de Tenerife, Spain
23 April 2022, 08:13
Estaba asignado mal la propiedad, gracias amigo! Esta no se me olvida, buena rotura de cerebro
Harvey Roberts
Level 9 , Helsinki, Finland
26 August 2021, 06:15
Cought me out six times b4 I realised I had to create the woman first. Doh!
Level 5 , Brisbane, Australia
3 April 2021, 09:32
I wish there was a way to block the pop ups after verification.
Joe M
Level 47 , Owings Mills, United States
27 August 2020, 20:49
1) create a new Woman, save with a variable name, her name 2) create a new Cat, save with the cat's name 3) catname.owner = woman's name 4) create a new Dog, save with dog's name 5) dogname.owner = woman's name 6) create a new fish, save with fish name 7)fishname.owner = woman's name That's it. don't touch anything but the main method.
Raunak Adhikari
Level 12 , India
12 August 2020, 12:52
it is easy....first make the 4 objects.....then assign them to the owners...let me give you and example... Elephant elephant = new Elephant(); Man man = new Man(); elephant.owner = man; eazy peasy....
Liliane Top
Level 17 , Amsterdam, Netherlands
5 February 2020, 13:14
I don't understand what we're actually doing here. Are we assigning a value of a variable to a class?? when using dog.owner = woman;
Anonymous #10772950
Level 8 , Delhi
5 August 2021, 09:12
What you're doing here is assigning a value to a variable. Here dog is an object and inside it is a variable called 'owner'. If you examine the code for the class Dog you will find a variable called 'owner' declared there which is of a type Woman. So when you create the dog object, it automatically has a variable called 'owner' inside it (as Objects contain whatever is there in the class they are born from). It is this variable dog.owner that has to be given a value, so effectively you are setting the value of this 'owner' variable to woman when you type dog.owner = woman;