mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
29 lines
878 B
Python
29 lines
878 B
Python
from behavioral.template.abstract_class import AbstractClass
|
|
|
|
|
|
class ConcreteClass1(AbstractClass):
|
|
"""
|
|
Concrete classes have to implement all abstract operations of the base
|
|
class. They can also override some operations with a default implementation.
|
|
"""
|
|
|
|
def required_operations1(self):
|
|
print("ConcreteClass1 says: Implemented Operation1")
|
|
|
|
def required_operations2(self):
|
|
print("ConcreteClass1 says: Implemented Operation2")
|
|
|
|
|
|
class ConcreteClass2(AbstractClass):
|
|
"""
|
|
Usually, concrete classes override only a fraction of base class' operations.
|
|
"""
|
|
|
|
def required_operations1(self):
|
|
print("ConcreteClass2 says: Implemented Operation1")
|
|
|
|
def required_operations2(self):
|
|
print("ConcreteClass2 says: Implemented Operation2")
|
|
|
|
def hook1(self):
|
|
print("ConcreteCLass2 says: Overridden Hook1")
|