def __init__(self,dataLine): #pass ''' constructor method Parameters: - dataLine with following data feilds - studID: student ID - name: name of student - test: test mark - iAsgn: individual assignment mark - gAsgn: group assignment mark - exam: exam mark ''' tokens = dataLine.split('_') ''' if (float(tokens[2]) < 0 or float(tokens[2]) > 100 or float(tokens[3]) < 0 or float(tokens[3]) > 100 or float(tokens[4]) < 0 or float(tokens[4]) > 100 or float(tokens[5]) < 0 or float(tokens[5]) > 100): raise ValueError("invalid mark value") elif tokens[1] == '': raise ValueError("invalid student name") elif len(tokens[0]) != 8: raise ValueError("invalid student number") ''' Student.__init__(self, int(tokens[0]), tokens[1]) self.__test = float(tokens[2]) self.__iAsgmt = float(tokens[3]) self.__gAsgmt = float(tokens[4])
def __init__(self, name, student_id, age, speciality, n, str_say_sth, str_say_bye, owner_name): #Student.__init__(self,name,student_id,age,speciality) #调用学生类构造方法 self.name = 'keke' #后续赋值语句覆盖此赋值语句 Assistant.__init__(self, str_say_sth, str_say_bye, n, owner_name) #调用助手类构造方法 Student.__init__(self, name, student_id, age, speciality) #调用学生类构造方法
def __init__(self, first_name, last_name, major, gpa, is_on_probation): Student.__init__(self, first_name, last_name, major, gpa, is_on_probation)