Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceKuhl committed Aug 20, 2024
1 parent f79b1b2 commit c4e5b3e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Days/mercedes_universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import datetime
from typing import List, Optional
from collections import namedtuple

Pet = namedtuple('Pet', ['name', 'specie'])

class Creature:
"""Creates a Creature which could be a human, werewolf or shapeshifter"""
Expand Down Expand Up @@ -43,14 +45,14 @@ def city(self) -> str:
else:
return None


class Shapeshifter(Creature):
"""Creates a Shapeshifter which turns into a specific animal"""

def __init__(self, name, gender, birthday, animal, city: City = None) -> None:
def __init__(self, name, gender, birthday, animal, city: City = None, pet: Pet = None) -> None:
super().__init__(name, gender, birthday)
self.animal = animal
self.human_shape = True
self.pet = pet

def __repr__(self):
"""returns the attributes of the shapeshifter"""
Expand All @@ -64,7 +66,10 @@ def shapeshift(self) -> None:
else:
self.human_shape = True
print(f"{self.name} swiftly turns back into a human!")


def adopt_pet(self, pet: Pet) -> None:
"""Adopts a pet"""
self.pet = pet

class Werewolf(Creature):
"""Creates a Werewolf which is either dominant or submissive and has a fur color"""
Expand Down Expand Up @@ -104,10 +109,10 @@ def rare(self) -> bool:
class City:
"""Defines a city of inhabitants, all of whom are Creatures"""

def __init__(self, name_city: str):
def __init__(self, name_city: str, position: Position = None) -> None:
self.name_city = name_city
self.creatures: List[Creature] = [] # Use forward reference with List[Creature]

@property
def name(self):
return self.name_city
Expand All @@ -133,8 +138,9 @@ def population_size(self) -> int:
return len(self.creatures)

if __name__ == "__main__":
mercy = Creature("Mercy", "F", datetime.datetime(1989, 6, 1))
mercy = Shapeshifter("Mercy", "F", datetime.datetime(1989, 6, 1), animal = 'coyote',pet = Pet(name="Meredith", specie="cat"))
mercy.speaks("Hey everyone")
print(mercy.city)
print(repr(mercy))
atlanta = City('Atlanta')
adam = Werewolf(
Expand All @@ -146,5 +152,8 @@ def population_size(self) -> int:
print(adam.rare())
atlanta.add_inhabitant(adam)
print(adam.city.name)
print(atlanta.survey_population())
oliver = Shapeshifter("Oliver", "M", datetime.datetime(1995, 9, 15), "owl")
oliver.shapeshift()
atlanta.add_inhabitant(oliver)
print(atlanta.population_size)

0 comments on commit c4e5b3e

Please sign in to comment.