Discuss / Python / 作业

作业

Topic source

beyond_24th

#1 Created at ... [Delete] [Delete and Lock User]

class Student(object):

    def __init__(self, name, gender):

        self.name = name

        self.__gender = gender

    def get_gender(self):

        return self.__gender

    def set_gender(self, new_gender):

        if new_gender == "male":

            self.__gender = "male"

        elif new_gender == "female":     

            self.__gender = "female"

        else:

            raise ValueError("输入错误")


  • 1

Reply