Skip to content

Instantly share code, notes, and snippets.

@longfin
Created September 22, 2015 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longfin/3288a358735f5eb88859 to your computer and use it in GitHub Desktop.
Save longfin/3288a358735f5eb88859 to your computer and use it in GitHub Desktop.
class Car:
def __init__(self, type):
self.type = type
class License:
def __init__(self, driver_name):
self.driver_name = driver_name
def print(self):
print("{}의 {}종 면허입니다.".format(self.driver_name, self.LICENSE_TYPE))
class FirstClassLicense(License):
def check(self, car):
return True
class SecondClassLicense(License):
def check(self, car):
return car.type == '소형'
class ThirdClassLicense(License):
def check(self, car):
return car.type == '대형'
# class OldLicense:
# def print(self):
# print("{}의 {}종 면허입니다.".format(self.driver_name, self.license_type))
# def check(self, car):
# if self.self_type == FIRST_LICENCE_TYPE:
# return True
# elif self.Self_type == THIRD_LICENCE_TYPE:
# return car.type == '대형'
# else:
# return car.type == '소형'
yang = FirstClassLicense('yang')
kwon = FirstClassLicense('kwon')
park = SecondClassLicense('park')
truck = Car(type='대형')
licenses = [yang, kwon, park]
for l in licenses:
if l.check(truck):
print(l.driver_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment