ZIP indir
0
main
1 dal
git@carbon4code.com:ahmet/Python-for-Data-Science.git
Ahmet Kerem Piscine Final
10 commit
S1E7.py 2.2 KB
from S1E9 import Character


class Baratheon(Character):
    """Representing the Baratheon family."""

    def __init__(self, first_name: str, is_alive: bool = True) -> None:
        """Build a Baratheon from a first name and a health state."""
        super().__init__(first_name, is_alive)
        self.family_name = "Baratheon"
        self.eyes = "brown"
        self.hairs = "dark"

    def __str__(self) -> str:
        """Return the family name, the eyes and the hairs as a string."""
        return f"Vector: {self.family_name, self.eyes, self.hairs}"

    def __repr__(self) -> str:
        """Return the same string representation as __str__."""
        return self.__str__()


class Lannister(Character):
    """Representing the Lannister family."""

    def __init__(self, first_name: str, is_alive: bool = True) -> None:
        """Build a Lannister from a first name and a health state."""
        super().__init__(first_name, is_alive)
        self.family_name = "Lannister"
        self.eyes = "blue"
        self.hairs = "light"

    def __str__(self) -> str:
        """Return the family name, the eyes and the hairs as a string."""
        return f"Vector: {self.family_name, self.eyes, self.hairs}"

    def __repr__(self) -> str:
        """Return the same string representation as __str__."""
        return self.__str__()

    @classmethod
    def create_lannister(cls, first_name: str,
                         is_alive: bool = True) -> "Lannister":
        """Create a Lannister without instantiating the class first."""
        return cls(first_name, is_alive)


def main() -> None:
    """Test the Baratheon and Lannister families."""
    Robert = Baratheon("Robert")
    print(Robert.__dict__)
    print(Robert.__str__)
    print(Robert.__repr__)
    print(Robert.is_alive)
    Robert.die()
    print(Robert.is_alive)
    print(Robert.__doc__)
    print("---")
    Cersei = Lannister("Cersei")
    print(Cersei.__dict__)
    print(Cersei.__str__)
    print(Cersei.is_alive)
    print("---")
    Jaine = Lannister.create_lannister("Jaine", True)
    print(f"Name : {Jaine.first_name, type(Jaine).__name__}, "
          f"Alive : {Jaine.is_alive}")


if __name__ == "__main__":
    main()