-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharizard.py
More file actions
54 lines (45 loc) · 2.56 KB
/
Copy pathCharizard.py
File metadata and controls
54 lines (45 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from Fire import Fire
from Charmeleon import Charmeleon
class Charizard(Charmeleon):
# This class represents objects of Charizard Pokemons.
def __init__(self, name, catch_rate, pokemon_type, level, hit_points, attack_power, defense_power):
Fire.__init__(self, name, catch_rate, pokemon_type)
if not isinstance(level, int): # Validating input type.
raise TypeError("Expected an Integer between 32-50")
if (level < 32) or (level > 50): # Validating input value.
raise ValueError("The Charizard level must be between 32-50")
self._level = level
if not isinstance(hit_points, int): # Validating input type.
raise TypeError("Expected an Integer between 78-99")
if (hit_points < 78) or (hit_points > 99): # Validating input value.
raise ValueError("The Charizard HP must be between 78-99")
self._hit_points = hit_points
self._original_hp = hit_points
if not isinstance(attack_power, int): # Validating input type.
raise TypeError("Expected an Integer between 84-99")
if (attack_power < 84) or (attack_power > 99): # Validating input value.
raise ValueError("The Charizard Attack Power must be between 84-99")
self._attack_power = attack_power
if not isinstance(defense_power, int): # Validating input type.
raise TypeError("Expected an Integer between 78-99")
if (defense_power < 78) or (defense_power > 99): # Validating input value.
raise ValueError("The Charizard Defense Power must be between 78-99")
self._defense_power = defense_power
def __repr__(self):
res = "The Charizard " + Charmeleon.__repr__(self)[15:]
return res
# The method returns the amount of damage (int) that the Charizard can put into the other Pokemon.
# The variable - other, is a Pokemon object. We assume that the input is valid.
def get_damage(self, other):
return int(Charmeleon.get_damage(self, other) + 2)
# The method updates the level of the Charizard.
def level_up(self, level_gain):
if not isinstance(level_gain, int): # Validating input type.
raise TypeError("Expected a positive Integer")
if level_gain < 0: # Validating input value.
raise ValueError("The variable level_gain must be a positive Integer")
# adding levels to current level.
self._level += level_gain
# A condition that makes sure that the max Charizard level is 50.
if self._level > 50:
self._level = 50