Proxy pattern: Difference between revisions

Content deleted Content added
PHP: type hinting
Python: type hint
Line 534:
 
class Car(AbstractCar):
def drive(self) -> None:
print("Car has been driven!")
 
 
class Driver(object):
def __init__(self, age: int) -> None:
self.age = age
 
 
class ProxyCar(AbstractCar):
def __init__(self, driver) -> None:
self.car = Car()
self.driver = driver
 
def drive(self) -> None:
if self.driver.age <= 16:
print("Sorry, the driver is too young to drive.")