# @property
# -*- coding: utf-8 -*-
# without property

# class Student(object):
#     def get_score(self):
#         return self._score
#
#     def set_score(self, value):
#         if not isinstance(value, int):
#             raise ValueError('score is not a integer!')
#         if value < 0 or value > 100:
#             raise ValueError('score must be 0~100!')
#         self._score = value
#
# s = Student()
# s.set_score('ss')

# using @property

class Student(object):

    @property
    def score(self):
        return self._score

    @score.setter
    def score(self, value):
        if not isinstance(value, int):
            raise ValueError('score is not a integer!')
        if value < 0 or value > 100:
            raise ValueError('score must be 0~100!')
        self._score = value
s = Student()
s.score = 10

# practice

class Screen(object):

    @property
    def width(self):
        return self._width

    @property
    def height(self):
        return self._height

    @property    
    def resolution(self):
        return self._height * self._width

    @width.setter
    def width(self, value):
        self._width = value

    @height.setter
    def height(self, value):
        self._height = value


s = Screen()
s.width = 1024
s.height = 768
print(s.resolution)
assert s.resolution == 786432, '1024 * 768 = %d ?' % s.resolution
