Declaring immutable fields
Pokemon Go is a location-based augmented-reality game in which players use the mobile device's GPS capability to locate, capture, train, and make virtual creatures fight. This game had great success and popularized location-based and augmented-reality gaming. After its great success, imagine that we have to develop a Web Service that will be consumed by a similar game that makes virtual creatures battle.
We have to move to the world of virtual creatures. We will definitely have a VirtualCreature
base class. Each specific type of virtual creature with unique characteristics that can participate in battles will be a subclass of VirtualCreature
.
All the virtual creatures will have a name and they will be born in a specific year. The age is going to be extremely important for their performance in battles. Thus, our base class will have the name
and birthYear
fields that all the subclasses will inherit.
When we design classes, we want to make sure that all the necessary...