-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18.14.py
More file actions
52 lines (39 loc) · 1.35 KB
/
18.14.py
File metadata and controls
52 lines (39 loc) · 1.35 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
class ObjCounter:
count = 0
obj_type = None
def __init__(self) -> None:
ObjCounter.obj_type = self.__class__.__name__
ObjCounter.count += 1
@staticmethod
def printcount():
print(f"Кількість: {ObjCounter.count}\nТип: {ObjCounter.obj_type}")
class Point2:
"""Клас реалізує точку площини"""
def __init__(self, x, y):
self._x = x
self._y = y
def get_x(self):
"""Повернути координату х"""
return self._x
def get_y(self):
"""Повернути координату y"""
return self._y
def __str__(self):
"""Повернути рядок представлення точки"""
return "({}, {})".format(self._x, self._y)
class Point2ObjCounter(ObjCounter, Point2):
def __init__(self, x, y) -> None:
ObjCounter.__init__(self)
Point2.__init__(self, x, y)
if __name__ == '__main__':
coords = '3, 4, 6, 8, 1, 2, 5, 5, 3, 3'
points = list(map(int, coords.split(', ')))
i = 0
if len(points) % 2 == 0:
while i != len(points):
p = Point2ObjCounter(points[i], points[i+1])
print(p)
i += 2
else:
raise Exception
Point2ObjCounter.printcount()