-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht2.py
More file actions
40 lines (37 loc) · 978 Bytes
/
t2.py
File metadata and controls
40 lines (37 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# class Student(object):
# @property
# def score(self):
# return self._score
# @score.setter
# def score(self,value):
# if not isinstance(value, int):
# raise ValueError('score must be an integer!')
# if value < 0 or value > 100:
# raise ValueError('score must between 0 ~ 100!')
# self._score = value
class Screen(object):
@property
def getWidth(self):
return self.width
@getWidth.setter
def setWidth(self,wid):
self.width=wid
@property
def getHeight(self):
return self.height
@getHeight.setter
def setHeight(self,height):
self.height=height
@property
def resolution(self):
self._resolution=self.width*self.height
return self._resolution
# 测试:
s = Screen()
s.width = 1024
s.height = 768
print('resolution =', s.resolution)
if s.resolution == 786432:
print('测试通过!')
else:
print('测试失败!')