Discuss / Python / 交作业

交作业

Topic source

v贝塔v

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

网页的代码缩进真的有毒,还是VScode好用

class Screen(object):
        @property
        def width(self):
            return self._width
	
        @width.setter
        def width(self,value):
            if not isinstance(value,int):
              raise ValueError('width must be integer.')
            elif not 1 <= value <= 1280:
                raise ValueError('width must between 0 - 1280.')
            self._width = value
	
        @property
        def height(self):
            return self._height
	
        @height.setter
        def height(self,value):
            if not isinstance(value,int):
                raise ValueError('height must be integer.')
            elif not 1 <= value <= 1096:
                raise ValueError('height must between 0 - 1096.')
            self._height = value
	
        @property
        def resolution(self):
            return self._width*self._height

  • 1

Reply