Extra Exercises¶
- The class,
Pokemon
, is provided below and describes a Pokemon and its leveling and evolving characteristics. An instance of the class is one pokemon that you create.Grass_Pokemon
is a subclass that inherits fromPokemon
but changes some aspects, for instance, the boost values are different. For the subclassGrass_Pokemon
, add another method calledaction
that returns the string “[name of pokemon] knows a lot of different moves!”. Create an instance of this class with the name as “Belle”. Assign this instance to the variablep1
.
- The attack strength for grass Pokemon does not change until they reach level 10. At level 10 and up, their attack strength increases by the attack_boost amount when they level. Modify the
Grass_Pokemon
subclass ofPokemon
to reflect this change. To test, create an instance of the class with the name as “Bulby”. Assign the instance to the variablep2
. Then, useGrass_Pokemon
methods to train a thep2
Grass_Pokemon instance until it reaches at least level 10.
- Along with the Pokemon parent class, we have also provided several subclasses. Write another method in the parent class that will be inherited by the subclasses called
opponent
that will show which type of pokemon the current type is weak against and strong against. For instance, if the p_type of the subclass is grass, fire will be assigned to the variableweak
and water will be assigned to the variablestrong
. Grass is weak against fire, but strong against water. Ghost is weak against dark but strong against psychic. Fire is weak against water but strong against grass. Finally, flying is weak against electric but strong against fighting.