Discuss / Python / 作业(测试通过)

作业(测试通过)

Topic source

I-cpp

#1 Created at ... [Delete] [Delete and Lock User]

class Screen(object):

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

@width.setter
def width(self, width):
    if not isinstance(width, (int, float)):
        raise ValueError("width应该为数值!")
    self._width = width

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

@height.setter
def height(self, height):
    if not isinstance(height, (int, float)):
        raise ValueError("height应该为数值!")
    self._height = height

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

  • 1

Reply