A group of tourists from Planet Tally visited a Terranian zoo. But all of the animals' nameplates had been stolen by robots who needed the metal for medication. We'll forgive the robots, but now we need to write a method that determines the type of objects passed to it (cat, lion, tiger, bull, cow, or generic animal).
Visitors
- 7
Locked
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Trevor
24 December 2019, 04:19
This is probably the 4th problem that asks us to determine the type of the object. Pointless.
+2
Adnan Razzaq
7 September 2019, 19:01
hello. I solved it by just changing tho positions of if statements and I m not sure why this happened. Can someone please explain this to me.
0
Devonte A
29 June 2020, 20:06
I think because instanceof will check the parent class first. So you must check the subtypes initially then the parent. Someone else may be able to elaborate.
+8