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}]}.
Serializing a zoo
- 14
Locked
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
joe
8 March 2021, 18:30
why wouldn't you add "type" to Zoo and put type = this.getClass().getSimpleName() in the Zoo constructor?
0