This project is a Python-based Pokédex system developed as part of the Ada Tech School curriculum. It implements Object-Oriented Programming principles to manage and analyze Pokémon data from a JSON file, with features like weight-based sorting and evolution chain tracking.
- Load and parse Pokémon data from JSON
- Track Pokémon evolutions (both next and previous)
- Filter Pokémons by weight
- Sort Pokémons by weight
- Strong typing implementation using Python type hints
project/
├── data/
│ └── pokedex.json # Source data file
├── src/
│ ├── pokedex.py # Main Pokédex class implementation
│ └── pokemon.py # Pokemon class definition
└── main.py # Example usage and execution
Represents individual Pokémon with attributes:
id
: Unique identifiername
: Pokémon nametype
: List of Pokémon typesheight
: Height in metersweight
: Weight in kgweaknesses
: List of type weaknessesnext_evolution
: Optional list of next evolution namesprev_evolution
: Optional list of previous evolution names
Manages the collection of Pokémon with methods:
get_list_len()
: Returns total number of Pokémonget_heavier_than_ten()
: Returns list of Pokémon weighing more than 10kgsorted_by_weight()
: Returns Pokémon list sorted by weightget_evolutions(pokemon_name)
: Returns evolution information for a specific Pokémon
from pokedex import Pokedex
import json
# Load data from JSON file
with open('data/pokedex.json', 'r', encoding='utf-8') as file:
pokedex_data = json.load(file)
# Create Pokedex instance
pokedex = Pokedex(pokedex_data)
# Get total number of Pokémon
print(pokedex.get_list_len())
# Get Pokémon heavier than 10kg
heavy_pokemon = pokedex.get_heavier_than_ten()
# Get sorted list by weight
sorted_pokemon = pokedex.sorted_by_weight()
# Check evolution chain
print(pokedex.get_evolutions("Eevee"))
- Uses Python's type hints for better code reliability
- Implements custom
__repr__
method for readable Pokémon representation - Handles optional evolution chains using
Optional
type - Includes weight conversion from string format (e.g., "10.0 kg") to float
- Clone this repository:
git clone [your-repository-url]
cd pokedex
- Ensure you have Python 3.x installed
- Place your
pokedex.json
file in thedata
directory
The project expects a JSON file with the following structure:
{
"pokemon": [
{
"id": 1,
"name": "Example",
"type": ["Type1", "Type2"],
"height": "0.7 m",
"weight": "6.9 kg",
"weaknesses": ["Type1", "Type2"],
"next_evolution": ["Evolution1"],
"prev_evolution": ["Evolution1"]
}
]
}
This is a school project for Ada Tech School. While it's not open for contributions, feedback and suggestions are welcome.
This project is part of Ada Tech School curriculum. All rights reserved.
- Ada Tech School for the project requirements and guidance
- Pokémon data provided as part of the course material