Skip to content

Commit 75bcb68

Browse files
author
Arjan Egges
committed
Fixed attributes attached to class instead of instance.
1 parent f17b736 commit 75bcb68

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

3 - strategy pattern/strategy-after-fn.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ def generate_id(length=8):
1010

1111

1212
class SupportTicket:
13-
id: str
14-
customer: str
15-
issue: str
1613

1714
def __init__(self, customer, issue):
1815
self.id = generate_id()
@@ -42,7 +39,8 @@ def blackHoleOrdering(list: List[SupportTicket]) -> List[SupportTicket]:
4239

4340
class CustomerSupport:
4441

45-
tickets: List[SupportTicket] = []
42+
def __init__(self):
43+
self.tickets = []
4644

4745
def create_ticket(self, customer, issue):
4846
self.tickets.append(SupportTicket(customer, issue))

3 - strategy pattern/strategy-after.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ def generate_id(length=8):
1010

1111

1212
class SupportTicket:
13-
id: str
14-
customer: str
15-
issue: str
1613

1714
def __init__(self, customer, issue):
1815
self.id = generate_id()
@@ -52,10 +49,8 @@ def create_ordering(self, list: List[SupportTicket]) -> List[SupportTicket]:
5249

5350
class CustomerSupport:
5451

55-
tickets: List[SupportTicket] = []
56-
processing_strategy: TicketOrderingStrategy = None
57-
5852
def __init__(self, processing_strategy: TicketOrderingStrategy):
53+
self.tickets = []
5954
self.processing_strategy = processing_strategy
6055

6156
def create_ticket(self, customer, issue):

3 - strategy pattern/strategy-before.py

-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ def generate_id(length=8):
99

1010

1111
class SupportTicket:
12-
id: str
13-
customer: str
14-
issue: str
1512

1613
def __init__(self, customer, issue):
1714
self.id = generate_id()
@@ -21,9 +18,6 @@ def __init__(self, customer, issue):
2118

2219
class CustomerSupport:
2320

24-
tickets: List[SupportTicket]
25-
processing_strategy: str
26-
2721
def __init__(self, processing_strategy: str = "fifo"):
2822
self.tickets = []
2923
self.processing_strategy = processing_strategy

0 commit comments

Comments
 (0)