Below is an example of how you can define a base class for Pokémon and implement specific Pokémon subclasses with unique attributes and abilities in Python:
```python
class Pokemon:
def __init__(self, name, pokemon_type, level):
self.name = name
self.type = pokemon_type
self.level = level
self.health = level * 10 # Set health based on level
self.strength = level * 2 # Set strength based on level
def __repr__(self):
return f"{self.name} - Type: {self.type}, Level: {self.level}, Health: {self.health}, Strength: {self.strength}"
class Pikachu(Pokemon):
def __init__(self, level=5):
super().__init__("Pikachu", "Electric", level)
self.attack = "Thunderbolt"
self.defense = "Quick Attack"
class Bulbasaur(Pokemon):
def __init__(self, level=5):
super().__init__("Bulbasaur", "Grass", level)
self.attack = "Vine Whip"
self.defense = "Razor Leaf"
class Charmander(Pokemon):
def __init__(self, level=5):
super().__init__("Charmander", "Fire", level)
self.attack = "Ember"
self.defense = "Scratch"
class Squirtle(Pokemon):
def __init__(self, level=5):
super().__init__("Squirtle", "Water", level)
self.attack = "Water Gun"
self.defense = "Bite"
class Mewtwo(Pokemon):
def __init__(self, level=70):
super().__init__("Mewtwo", "Psychic", level)
self.attack = "Psychic"
self.defense = "Barrier"
```
In this example:
- We define a base class `Pokemon` with attributes such as name, type, level, health, and strength. The `__init__` method initializes these attributes based on the input level.
- We then create specific Pokémon subclasses such as `Pikachu`, `Bulbasaur`, `Charmander`, `Squirtle`, and `Mewtwo`, each of which inherits from the `Pokemon` class.
- Each specific Pokémon subclass initializes the base attributes through the `super().__init__` call and sets unique attributes like attacks (`attack`) and defenses (`defense`) specific to that Pokémon.
You can now create objects of these Pokémon classes to represent individual Pokémon and their attributes:
```python
pikachu = Pikachu(10)
bulbasaur = Bulbasaur(8)
charmander = Charmander(12)
squirtle = Squirtle(9)
mewtwo = Mewtwo(70)
print(pikachu)
print(bulbasaur)
print(charmander)
print(squirtle)
print(mewtwo)
```
When you run this code, it will create Pokémon objects with their specific attributes such as name, type, level, health, strength, and unique attacks and defenses. This provides a foundation for organizing Pokémon classes and objects with their associated attributes and abilities as part of the Pokémon-themed learning guide.