Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend #3

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added hashmap.py
mfahd308 authored Dec 3, 2024
commit 8b93e3f65d1379611ef60a19c18f088795c18ae2
31 changes: 31 additions & 0 deletions hashmap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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