Discuss / Python / 作业

作业

Topic source

田俊俊

#1 Created at ... [Delete] [Delete and Lock User]
class Screen(object):

    @property
    def width(self):
        return self._width;
    @width.setter
    def width(self,width):
        self._width = width;

    @property
    def height(self):
        return self._height;
    @height.setter
    def height(self,height):
        self._height = height;

    @property
    def resolution(self):
        return self._resolution;

    def __init__(self):
        self._width=10
        self._height=20
        self._resolution=30
    def toString(self):
        print("self width :%d ,height :%d , resolution %d" %
              (self._width ,self._height,self._resolution))

s=Screen()
s.width=21
s.height=32
print("main width :%d ,height :%d , resolution %d" %
              (s.width ,s.height,s.resolution))
s.toString()

  • 1

Reply