class Screen(object):
@property#读宽度
def width(self):
return self._width
@width.setter
def width(self,value):
if not isinstance(value,int):
raise TypeError('Bad type')
else:
self._with=value
@property # 读高度度
def height(self):
return self._height
@height.setter
def height(self, value):
if not isinstance(value, int):
self._height = value
@property
def resolution(self):
return self._height*self._with
Sign in to make a reply
Haley要fighting
class Screen(object):
@property#读宽度
def width(self):
return self._width
@width.setter
def width(self,value):
if not isinstance(value,int):
raise TypeError('Bad type')
else:
self._with=value
@property # 读高度度
def height(self):
return self._height
@height.setter
def height(self, value):
if not isinstance(value, int):
raise TypeError('Bad type')
else:
self._height = value
@property
def resolution(self):
return self._height*self._with