|
| 1 | +class PokemonBasic: |
| 2 | + def __init__(self, name="Default", hp=0, weakness="None", type="Unknown"): |
| 3 | + self.name = name |
| 4 | + self.hit_point = hp |
| 5 | + self.weakness = weakness |
| 6 | + self.type = type |
| 7 | + |
| 8 | + def get_type(self): |
| 9 | + return "Main type: " + self.type |
| 10 | + |
| 11 | + def get_move(self): |
| 12 | + return "Basic move: " + "Quick Attack" |
| 13 | + |
| 14 | + def __str__(self): |
| 15 | + return ( |
| 16 | + "Name: " |
| 17 | + + self.name |
| 18 | + + ", HP: " |
| 19 | + + str(self.hit_point) |
| 20 | + + ", Weakness: " |
| 21 | + + self.weakness |
| 22 | + ) |
| 23 | + |
| 24 | + |
| 25 | +class PokemonExtra(PokemonBasic): |
| 26 | + def __init__( |
| 27 | + self, |
| 28 | + name="Defalut", |
| 29 | + hp=0, |
| 30 | + weakness=None, |
| 31 | + type=None, |
| 32 | + secondary=None, |
| 33 | + *extra_moves, |
| 34 | + ): |
| 35 | + super().__init__(name, hp, weakness, type) |
| 36 | + self.secondary = secondary |
| 37 | + self.extra_moves = extra_moves |
| 38 | + |
| 39 | + self.move_lst = list(self.extra_moves) |
| 40 | + self.var1 = [] |
| 41 | + self.var2 = "" |
| 42 | + for i in self.extra_moves: |
| 43 | + self.var1 = list(i) |
| 44 | + self.var2 += ", ".join(self.var1) |
| 45 | + |
| 46 | + def get_type(self): |
| 47 | + if self.secondary == None: |
| 48 | + return f"Main type: {self.type}" |
| 49 | + else: |
| 50 | + return f"Main type: {self.type} Secondary type: {self.secondary}" |
| 51 | + |
| 52 | + def get_move(self): |
| 53 | + if len(self.extra_moves) == 0: |
| 54 | + return "Basic move: Quick Attack" |
| 55 | + else: |
| 56 | + return f"Basic move: Quick Attack\nOther moves: {str(self.var2)}" |
| 57 | + |
| 58 | + |
| 59 | +print("\n------------Basic Info:--------------") |
| 60 | +pk = PokemonBasic() |
| 61 | +print(pk) |
| 62 | +print(pk.get_type()) |
| 63 | +print(pk.get_move()) |
| 64 | +print("\n------------Pokemon 1 Info:-------------") |
| 65 | +charmander = PokemonExtra("Charmander", 39, "Water", "Fire") |
| 66 | +print(charmander) |
| 67 | +print(charmander.get_type()) |
| 68 | +print(charmander.get_move()) |
| 69 | +print("\n------------Pokemon 2 Info:-------------") |
| 70 | +charizard = PokemonExtra( |
| 71 | + "Charizard", 78, "Water", "Fire", "Flying", ("Fire Spin", "Fire Blaze") |
| 72 | +) |
| 73 | +print(charizard) |
| 74 | +print(charizard.get_type()) |
| 75 | +print(charizard.get_move()) |
0 commit comments