设计一个老师类的Teacher,描述老师的信息(年龄,姓名)职责(教学) 设计一个学生类的Student,描述学生的信息(姓名,年龄)和职责(学习)
时间: 2024-05-27 19:14:00 浏览: 154
java person类
class Teacher:
def __init__(self, age, name):
self.age = age
self.name = name
def teach(self):
print(f"{self.name} is teaching the class.")
class Student:
def __init__(self, age, name):
self.age = age
self.name = name
def study(self):
print(f"{self.name} is studying for the exam.")
阅读全文