-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlastoise.py
More file actions
54 lines (45 loc) · 2.56 KB
/
Copy pathBlastoise.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 Water import Water
from Wartortle import Wartortle
class Blastoise(Wartortle):
# This class represents objects of Blastoise Pokemons.
def __init__(self, name, catch_rate, pokemon_type, level, hit_points, attack_power, defense_power):
Water.__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 Blastoise level must be between 32-50")
self._level = level
if not isinstance(hit_points, int): # Validating input type.
raise TypeError("Expected an Integer between 80-99")
if (hit_points < 80) or (hit_points > 99): # Validating input value.
raise ValueError("The Blastoise HP must be between 80-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 83-99")
if (attack_power < 83) or (attack_power > 99): # Validating input value.
raise ValueError("The Blastoise Attack Power must be between 83-99")
self._attack_power = attack_power
if not isinstance(defense_power, int): # Validating input type.
raise TypeError("Expected an Integer between 100-115")
if (defense_power < 100) or (defense_power > 115): # Validating input value.
raise ValueError("The Blastoise Defense Power must be between 100-115")
self._defense_power = defense_power
def __repr__(self):
res = "The Blastoise " + Wartortle.__repr__(self)[14:]
return res
# The method returns the amount of damage (int) that the Blastoise 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(Wartortle.get_damage(self, other) - 1)
# The method updates the level of the Blastoise.
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 Blastoise level is 50.
if self._level > 50:
self._level = 50