示例#1
0
文件: main.py 项目: akulaj9/classwork
def main():
    student1 = Student('Ivan', 18)
    print(type(student1), id(student1))

    student2 = Student('Mariya', 18)
    print(type(student2), id(student2))

    #student1.name = 'Ivan Ivanov'
    #student1.age = 18
    print(student1.name, student1.age)
    student1.age += 1
    print(student1.name, student1.age)

    print(student2.name, student2.age)
    student2.name = 'Alice'
    print(student2.name, student2.age)

    student1.accept_task(1)
    student1.accept_task(3)
    student1.accept_task(5)
    student1.print_info()
    student2.accept_test(12)
    student2.print_info()

    # print(type(Student))
    #
    # pp(student1.__dict__)
    # student1.__dict__['name'] = 'IVAN'
    # print(student1.name)
    #
    # pp(Student.__dict__)

    prof1 = Professor('Dr. Who', 42)
    prof1.salary = 1000
    prof1.print_info()
    print(prof1)
    print(prof1.salary)
示例#2
0
    student1.print_info()
    student2.print_info()
    student3.print_info()

    # pprint.pprint(Student.__dict__)
    # pprint.pprint(student1.__dict__)
    student1.__dict__['name'] = 'William'
    print(student1.__dict__['name'])
    print(student1.name)

    print(
        '===================================================================================='
    )
    print('NEW')
    print(
        '===================================================================================='
    )
    pr1 = Professor('Donald Knuth', 42)
    pr1.print_info()
    pr1.salary = 1000
    pr1.print_info()

    print(pr1.groups)
    #
    # print(pr1.get_group())
    pr1._groups = ["Math", "CS", "ML", "AI"]
    # print(pr1.get_group())
    print(pr1.group)
    print(student1.__str__())
    student_str = str(student1)
    print(student_str)