class Student(object):
def __init__(self,name = 'ljh',score = 90):
self.__name = name
self.__score = score
def set_name(self,name):
self.__name = name
def get_name(self):
return self.__name
def set_score(self,score):
if 0 <= score <= 100:
self.__score = score
else:
raise ValueError('bad score')
def get_score(self):
return self.__score
def get_grade(self):
if self.__score >= 90:
return 'A'
else:
return 'B'
def print_score(self):
print('%s:%d' % (self.__name,self.__score))
bart = Student(score = 89)
print(bart._Student__name,bart._Student__score)
bart.name = 'xll'
bart.print_score()
print(bart.get_name())
print(bart.get_score())
bart.set_name('xll')
bart.set_score(98)
print(bart.get_name())
print(bart.get_score())
print(bart.get_grade())
def __init__(self,name = 'ljh',score = 90):
self.__name = name
self.__score = score
def set_name(self,name):
self.__name = name
def get_name(self):
return self.__name
def set_score(self,score):
if 0 <= score <= 100:
self.__score = score
else:
raise ValueError('bad score')
def get_score(self):
return self.__score
def get_grade(self):
if self.__score >= 90:
return 'A'
else:
return 'B'
def print_score(self):
print('%s:%d' % (self.__name,self.__score))
bart = Student(score = 89)
print(bart._Student__name,bart._Student__score)
bart.name = 'xll'
bart.print_score()
print(bart.get_name())
print(bart.get_score())
bart.set_name('xll')
bart.set_score(98)
print(bart.get_name())
print(bart.get_score())
print(bart.get_grade())