Discuss / Python / 作业

作业

Topic source

EddieLau_

#1 Created at ... [Delete] [Delete and Lock User]
class Screen(object):
    def __init__(self, width = 0, height = 0):
        self._width = 0
        self._height = 0

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

    @width.setter
    def width(self, width):
        if isinstance(width, int) == False: raise ValueError('"width"参数类型非法!')
        self._width = width

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

    @height.setter
    def height(self, height):
        if isinstance(height, int) == False: raise ValueError('"height"参数类型非法!')
        self._height = height

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

  • 1

Reply