"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!
Pets need people
- 3
Locked
Comments (43)
- Popular
- New
- Old
You must be signed in to leave a comment
David
14 March, 17:24
Me estaba volviendo loco, solo tenía una variable mal escrita. Ojo con los errores .😋
0
Lunita
21 December 2022, 15:56
It was pretty easy for me! I just remembered previous lessons. It's exactly what they taught. 😁
0
Dav
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. :(
0
Lunita
21 December 2022, 15:57
Try reviewing previous lessons.
0
Jeff Kenney
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();
+4
Anonymous #10829459
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
+3
Nuhazet
23 April 2022, 08:13
Estaba asignado mal la propiedad, gracias amigo! Esta no se me olvida, buena rotura de cerebro
0
Harvey Roberts
26 August 2021, 06:15
Cought me out six times b4 I realised I had to create the woman first. Doh!
0
Luke
3 April 2021, 09:32
I wish there was a way to block the pop ups after verification.
+2
Joe M
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.
+2
Raunak Adhikari
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....
+5
Liliane Top
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;
0
Anonymous #10772950
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;
+1