Discuss / Python / 交作业

交作业

Topic source
class Screen(object):
    def __init__(self):
        pass
    @property
    def width(self):
        return self._width

    @width.setter
    def width(self,value):
        if isinstance(value,int):
            self._width = value
        else:
            print("The value must be a integer.")

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

    @height.setter
    def height(self,value):
        if isinstance(value,int):
            self._height = value
        else:
            print("The value must be a interger.")

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

  • 1

Reply