-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy path38_pokedex_1.py
More file actions
39 lines (31 loc) · 1.31 KB
/
38_pokedex_1.py
File metadata and controls
39 lines (31 loc) · 1.31 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
# Pokédex 📟
# Codédex
# Class definition
class Pokemon:
def __init__(self, entry, name, types, description, is_caught):
self.entry = entry
self.name = name
self.types = types
self.description = description
self.is_caught = is_caught
def speak(self):
print(self.name + ', ' + self.name + '!')
def display_details(self):
print('Entry Number: ' + str(self.entry))
print('Name: ' + self.name)
if len(self.types) == 1:
print('Type: ' + self.types[0])
else:
print('Type: ' + self.types[0] + '/' + self.types[1])
print('Description: ' + self.description)
if self.is_caught:
print(self.name + ' has already been caught!')
else:
print(self.name + ' hasn\'t been caught yet.')
# Pokémon objects
pikachu = Pokemon(25, 'Pikachu', ['Electric'], 'It has small electric sacs on both its cheeks. If threatened, it looses electric charges from the sacs.', True)
charizard = Pokemon(6, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', False)
gyarados = Pokemon(130, 'Gyarados', ['Water', 'Flying'], 'It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.', False)
pikachu.speak()
charizard.speak()
gyarados.speak()