Untitled

mail@pastecode.io avatar
unknown
python
a year ago
1.2 kB
12
Indexable
Never
from typing import List

class Person():
    def __init__(self, name, age: int) -> None:
        self.name = name
        self.age = age


class Student(Person):
    def __init__(self, name, age) -> None:
        super().__init__(name, age)
        self.knowledge = 0
    
    
    def get_knowledge(self):
        self.knowledge += 1


class Teacher(Person):
    def __init__(self, name, age, students: List[Student]) -> None:
        super().__init__(name, age)
        self.students = students

    def teach(self):
        for i in range(len(self.students)):
            self.students[i].get_knowledge()
            print(self.students[i].name + ": " + str(self.students[i].knowledge))


class Assistent(Teacher, Student):
    def __init__(self, name, age, students: List[Student]) -> None:
        super().__init__(name, age, students)


if __name__ == "__main__":
    st1 = Student("Vasya", 54)
    st2 = Student("Petya", 54)
    st3 = Student("Kolya", 54)
    ass = Assistent("Lox", 3, [st1, st2, st3])
    techer1 = Teacher("Alan", 8, [st1, st2, st3, ass])
    techer1.teach()
    techer1.teach()
    ass.get_knowledge()
    techer1.teach()