Created
January 9, 2019 14:25
-
-
Save nidev/c83bf77c0e0d9bee1d4a691cede10a5a to your computer and use it in GitHub Desktop.
태보는 지금 전세계적으로 선풍적인 인기를 끌고 있는데요
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
class Sport: | |
def runtime_minutes(self): | |
raise NotImplementedError('Please implement this method') | |
class Taekwondo(Sport): | |
def __add__(self, other): | |
if instanceof(other, Boxing): | |
return Taebo() | |
return super.__add__(other) | |
class Boxing(Sport): | |
def __add__(self, other): | |
if instanceof(other, Taekwondo): | |
return Taebo() | |
class Taebo(Sport): | |
def __str__(self): | |
pass | |
def __repr__(self): | |
return '태보란 우리나라의 태권도와 복싱을 접목한 운동입니다!' | |
def is_famous(self): | |
return True | |
def runtime_minutes(self): | |
return 25 | |
class User: | |
def __init__(self): | |
self._has_good_shape = False | |
self._taebo_training_for_months = 0 | |
def perform_exercise(self, month=0, sport_object=None): | |
assert month >= 0 | |
assert sport_object is not None | |
if isinstance(sport_object, Taebo): | |
self._taebo_training_for_months += month | |
else: | |
# 절 대 태 보 해 | |
pass | |
if self._taebo_training_for_months >= 2: | |
self._has_good_shape = True | |
def has_good_shape(self): | |
return self._has_good_shape | |
def say_hello(self): | |
print('안녕하세요~~~~') | |
class TaeboWorld: | |
def __init__(self): | |
pass | |
def __enter__(self): | |
print('JAB JAB JAB JAB PUNCH HOOK!') | |
def __exit__(self, *args): | |
if taebo is None: | |
print('이게 태보에서 쉬는 동작입니다') | |
if __name__ == '__main__': | |
# 조혜련과 태보의 저주 초기화 | |
worldwide = globals() | |
worldwide['taebo'] = Taebo() | |
boxing = Boxing() | |
taekwondo = Taekwondo() | |
hrj = User() | |
# 대사 시작 | |
hrj.say_hello() | |
if taebo.is_famous() and 'taebo' in worldwide: | |
print('태보는 지금 전세계적으로 선풍적인 인기를 끌고 있는데요!') | |
while not hrj.has_good_shape(): | |
hrj.perform_exercise(month=1, sport_object=taebo) | |
if hrj.has_good_shape(): | |
print('2달 동안 태보를 했더니 조혜련이 이렇게 완벽한 몸매가 됐습니다') | |
# TODO: 태보 25분 한 것과 러닝머신 한 시간 한 것을 __eq__로 구현해줘야한다 | |
print('태보를 하루에 {}분만 투자한다면 런닝머신 한시간!'.format(taebo.runtime_minutes())) | |
print('여러분도 하루에 {}분만! 태보의 세계로 들어가봅시다!'.format(taebo.runtime_minutes())) | |
for i in range(25): | |
# this calls __enter__, __enter__ the world of Tae-bo. | |
with TaeboWorld(): | |
if i == 24: | |
globals()['taebo'] = None | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment