Skip to content

Commit 99a4675

Browse files
committed
structural design pattern to ensure all location services are contained inside the composite class
1 parent 1c7e4ae commit 99a4675

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app/services/location/Composite.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
class Composite(LocationService):
3+
4+
5+
def init(self):
6+
self._children: List[Component] = []
7+
8+
9+
def add(self, LocationService):
10+
self._children.append(LocationService)
11+
component.parent = self
12+
13+
def remove(self, LocationService) -> None:
14+
self._children.remove(LocationService)
15+
component.parent = None
16+
17+
def is_composite(self) -> bool:
18+
return True
19+
20+
def operation(self):
21+
for child in self._children:
22+
child.getLocations()

0 commit comments

Comments
 (0)