姓名name、学号ID、性别gender、专业majoy、出生年月date、兴趣爱好hobby
时间: 2023-07-03 17:26:27 浏览: 86
好的,那么我来为student类添加这些属性和方法:
```python
class Student:
def __init__(self, name, ID, gender, major, date, hobby):
self.name = name
self.ID = ID
self.gender = gender
self.major = major
self.date = date
self.hobby = hobby
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_ID(self):
return self.ID
def set_ID(self, ID):
self.ID = ID
def get_gender(self):
return self.gender
def set_gender(self, gender):
self.gender = gender
def get_major(self):
return self.major
def set_major(self, major):
self.major = major
def get_date(self):
return self.date
def set_date(self, date):
self.date = date
def get_hobby(self):
return self.hobby
def set_hobby(self, hobby):
self.hobby = hobby
```
这样,你的student类就拥有了姓名、学号、性别、专业、出生年月、兴趣爱好等属性,同时也有了对应的getter和setter方法,可以方便地获取和修改对象的属性。
阅读全文