forked from COP3530/P2-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashmap.py
More file actions
31 lines (20 loc) · 756 Bytes
/
hashmap.py
File metadata and controls
31 lines (20 loc) · 756 Bytes
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
class GameHashMap:
def __init__(self, games):
"""initialize hash map with given data"""
self.game_map = {}
self._create_game_hash_map(games)
def _create_game_hash_map(self, games):
"""fill hash map"""
for game in games:
self.game_map[game.title] = {
"genre": game.genre,
"rating": game.rating,
"platform": game.platform
}
def search_game_by_title(self, title):
"""search for game with title"""
title_lower = title.lower()
for key in self.game_map.keys():
if key.lower() == title_lower: # case-insensitive match for search
return self.game_map[key]
return None