Discuss / Python / 交作业

交作业

Topic source

rrke

#1 Created at ... [Delete] [Delete and Lock User]
class Screen(object):

    def check(self,n):
        if not isinstance(n,int):
            raise TypeError('expect int type')
        if 0 > n:
            raise Exception('expect bigger than 0')

    @property
    def width(self):

        return self._width

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


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

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

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

  • 1

Reply