Skip to content

Advanced object-oriented: Possible solution for Eye Color Exercise #322

Open
@HaBeSte

Description

@HaBeSte
class Eye:
    def __init__(self, color):
        self.color = color

class Mother(Eye):
    def __init__(self, color):
        super().__init__(color)

class Father(Eye):
    def __init__(self, color):
        super().__init__(color)

class Child(Eye):
    def __init__(self, mom: Mother, dad: Father):
        result = "blue"
        if "brown" in [mom.color, dad.color]:
            result = "brown" 
        super().__init__(result)

mom = Mother("blue")
dad = Father("blue")
kid = Child(mom, dad)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions