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

Requirements #13

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HW/HW3 Design/wildlife_tracker/Goal.docx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 10 additions & 1 deletion HW/HW3 Design/wildlife_tracker/animal_management/animal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from typing import Any, Optional

class Animal:
def __init__(self, animal_id: int, name: str, species: str, age: Optional[int] = None, health_status: Optional[str] = None):

self.animal_id = animal_id # Unique ID for the animal
self.name = name # Name of the animal
self.species = species # Species of the animal
self.age = age # Optional age of the animal
self.health_status = health_status # Optional health status of the animal

def __repr__(self):
return f"Animal(ID={self.animal_id}, Name={self.name}, Species={self.species}, Age={self.age}, Health Status={self.health_status})"

pass
16 changes: 12 additions & 4 deletions HW/HW3 Design/wildlife_tracker/animal_management/animal_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
class AnimalManager:

def __init__(self) -> None:
animals: dict[int, Animal] = {}
self.animals: dict[int, Animal] = {}

def get_animal_by_id(self, animal_id: int) -> Optional[Animal]:
pass
return self.animals.get(animal_id, None)

def register_animal(self, Animal) -> None:
pass
if Animal.animal_id not in self.animals:
self.animals[Animal.animal_id] = Animal
print(f"Animal with ID {Animal.animal_id} registered.")
else:
print(f"Animal with ID {Animal.animal_id} already exists.")

def remove_animal(self, animal_id: int) -> None:
pass
if animal_id in self.animals:
del self.animals[animal_id]
print(f"Animal with ID {animal_id} removed.")
else:
print(f"Animal with ID {animal_id} not found.")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 17 additions & 4 deletions HW/HW3 Design/wildlife_tracker/habitat_management/habitat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, List, Optional
from wildlife_tracker.animal_management.animal import Animal

class Habitat:

Expand All @@ -20,13 +21,25 @@ def __init__(self,
self.animals = animals or []

def update_habitat_details(self, **kwargs: dict[str: Any]) -> None:
pass
for key, value in kwargs.items():
if hasattr(self, key):
setattr(self, key, value)
print(f"Habitat {self.habitat_id} details updated.")

def assign_animals_to_habitat(self, animals: List[Animal]) -> None:
pass
for animal in animals:
if animal not in self.animals:
self.animals.append(animal)
print(f"Assigned animals to habitat {self.habitat_id}.")

def get_animals_in_habitat(self) -> List[Animal]:
pass
return self.animals

def get_habitat_details(self) -> dict:
pass
return {
"habitat_id": self.habitat_id,
"geographic_area": self.geographic_area,
"size": self.size,
"environment_type": self.environment_type,
"animals": self.animals
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
from typing import Optional, List

from wildlife_tracker.habitat_management.habitat import Habitat
from wildlife_tracker.animal_management.animal import Animal

class HabitatManager:

pass
def __init__(self) -> None:
self.habitats: dict[int, Habitat] = {}

def register_habitat(self, habitat_id: int, geographic_area: str, size: int, environment_type: str) -> Habitat:
if habitat_id not in self.habitats:
habitat = Habitat(habitat_id, geographic_area, size, environment_type)
self.habitats[habitat_id] = habitat
print(f"Habitat {habitat_id} registered.")
return habitat
else:
print(f"Habitat {habitat_id} already exists.")
return self.habitats[habitat_id]

def remove_habitat(self, habitat_id: int) -> None:
if habitat_id in self.habitats:
del self.habitats[habitat_id]
print(f"Habitat {habitat_id} removed.")
else:
print(f"Habitat {habitat_id} not found.")

def get_habitat_by_id(self, habitat_id: int) -> Optional[Habitat]:
return self.habitats.get(habitat_id)

def get_habitats_by_geographic_area(self, geographic_area: str) -> List[Habitat]:
return [habitat for habitat in self.habitats.values() if habitat.geographic_area == geographic_area]

def get_habitats_by_size(self, size: int) -> List[Habitat]:
return [habitat for habitat in self.habitats.values() if habitat.size == size]

def get_habitats_by_type(self, environment_type: str) -> List[Habitat]:
return [habitat for habitat in self.habitats.values() if habitat.environment_type == environment_type]

def assign_animals_to_habitat(self, habitat_id: int, animals: List[Animal]) -> None:
habitat = self.get_habitat_by_id(habitat_id)
if habitat:
habitat.assign_animals_to_habitat(animals)
else:
print(f"Habitat with ID {habitat_id} not found.")

def get_animals_in_habitat(self, habitat_id: int) -> Optional[List[Animal]]:
habitat = self.get_habitat_by_id(habitat_id)
if habitat:
return habitat.get_animals_in_habitat()
else:
print(f"Habitat with ID {habitat_id} not found.")
return None

def get_habitat_details(self, habitat_id: int) -> Optional[dict]:
habitat = self.get_habitat_by_id(habitat_id)
if habitat:
return habitat.get_habitat_details()
else:
print(f"Habitat with ID {habitat_id} not found.")
return None

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 15 additions & 2 deletions HW/HW3 Design/wildlife_tracker/migration_tracking/migration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from typing import Any
from typing import List, Optional
from wildlife_tracker.animal_management.animal import Animal
from wildlife_tracker.habitat_management.habitat import Habitat

class Migration:
def __init__(self, migration_id: int, animals: List[Animal], destination: Habitat, duration: Optional[int] = None, current_location: Optional[Habitat] = None):
self.migration_id = migration_id
self.animals = animals
self.destination = destination
self.current_location = current_location
self.duration = duration

pass
def update_details(self, destination: Optional[Habitat] = None, duration: Optional[int] = None) -> None:
if destination:
self.destination = destination
if duration:
self.duration = duration
print(f"Migration {self.migration_id} details updated.")
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
from typing import Optional

from typing import List, Optional
from wildlife_tracker.migration_tracking.migration import Migration
from wildlife_tracker.animal_management.animal import Animal
from wildlife_tracker.habitat_management.habitat import Habitat

class MigrationManager:
def __init__(self) -> None:
self.migrations: dict[int, Migration] = {}

def register_migration(self, migration_id: int, animals: List[Animal], destination: Habitat, duration: Optional[int] = None) -> Migration:
if migration_id not in self.migrations:
migration = Migration(migration_id, animals, destination, duration)
self.migrations[migration_id] = migration
print(f"Migration {migration_id} registered.")
return migration
else:
print(f"Migration {migration_id} already exists.")
return self.migrations[migration_id]

def remove_migration(self, migration_id: int) -> None:
if migration_id in self.migrations:
del self.migrations[migration_id]
print(f"Migration {migration_id} removed.")
else:
print(f"Migration {migration_id} not found.")

def get_migration_by_id(self, migration_id: int) -> Optional[Migration]:
return self.migrations.get(migration_id)

def retrieve_migrations(self) -> List[Migration]:
return list(self.migrations.values())

def update_migration(self, migration_id: int, destination: Optional[Habitat] = None, duration: Optional[int] = None) -> None:
migration = self.get_migration_by_id(migration_id)
if migration:
migration.update_details(destination, duration)
else:
print(f"Migration with ID {migration_id} not found.")

def schedule_migration(self, migration_id: int) -> None:
if migration_id in self.migrations:
print(f"Migration {migration_id} scheduled.")
else:
print(f"Migration with ID {migration_id} not found.")

def cancel_migration(self, migration_id: int) -> None:
if migration_id in self.migrations:
print(f"Migration {migration_id} canceled.")
else:
print(f"Migration with ID {migration_id} not found.")

pass
def get_migrations_by_destination(self, destination: Habitat) -> List[Migration]:
return [migration for migration in self.migrations.values() if migration.destination == destination]
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
from typing import Optional
from wildlife_tracker.habitat_management.habitat import Habitat

class MigrationPath:
def __init__(self, species: str, start_location: Habitat, end_location: Habitat, duration: int):
self.species = species
self.start_location = start_location
self.end_location = end_location
self.duration = duration

pass
def update_path_details(self, species: Optional[str] = None, start_location: Optional[Habitat] = None, end_location: Optional[Habitat] = None, duration: Optional[int] = None) -> None:
if species:
self.species = species
if start_location:
self.start_location = start_location
if end_location:
self.end_location = end_location
if duration:
self.duration = duration
print("Migration path details updated.")