Serializing a zoo

  • 14
  • Locked
Make it so that a type is added to each element of the animals list when you serialize a Zoo object (dog for the Dog class, cat for the Cat class). To check, you can use the Solution class's main method. Before: {"animals":[{"name":"doggy","barkVolume":0.0},{"name":"catty","lives":0}]}.
You can't complete this task, because you're not signed in.
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
joe
Level 27 , London, United Kingdom
8 March 2021, 18:30
why wouldn't you add "type" to Zoo and put type = this.getClass().getSimpleName() in the Zoo constructor?