-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathex50.py
More file actions
34 lines (26 loc) · 814 Bytes
/
ex50.py
File metadata and controls
34 lines (26 loc) · 814 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
#!/home/wizard/anaconda3/bin/python
class Point():
# Конструктор на класа
def __init__(self, x=0, y=0):
print('Constructor Point')
self.__x = x # променлива на обекта
# x = 10 # локална променлива
self.__y = y
# Методи на класа
def moveTo(self, dx,dy):
self.__x += dx
self.__y += dy
def show(self):
print(f'Draw Point:({self.__x},{self.__y})')
if __name__ == '__main__':
# Point - клас; типа, който сме създали
# p1 - обект; екземпляр от типа Point
print('begin')
p1 = Point()
print('end')
# p1.__x = 100
p1.show()
p1.moveTo(-30,20)
p1.show()
p2 = Point(120,300)
p2.show()