Created
September 22, 2015 11:48
-
-
Save longfin/3288a358735f5eb88859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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