I couldn't help writing it because I was struck by the fact that the repetition of "-ya-na-ka" and "-cha-ya-na-ka" was easy to incorporate into the conditional branching of programming languages (?).
Is it like this if you want to reproduce the corn flakes material?
class Breakfast:
def is_sweet(self):
return True
def is_crunchy(self):
return True
def is_eaten_with_milk(self):
return True
def is_good_for_dinner(self):
return True
def is_eaten_by_monk(self):
return True
def exists_at_bottom_of_parfait(self):
return True
def is_chinese(self):
return True
class Mother:
def good_for_the_last_supper(self, breakfast):
return True
def knows_why_pentagon_is_big(self, breakfast):
return False
def used_to_adored(self, breakfast):
return True
def knows_who_to_thank(self, breakfast):
return False
def corn_flakes(self, breakfast):
return False
class Father:
def predict(self, breakfast, corn_flakes):
if not corn_flakes:
return "Grilled mackerel with salt"
mother = Mother()
breakfast = Breakfast()
corn_flakes = False
if breakfast.is_sweet() and breakfast.is_crunchy() and breakfast.is_eaten_with_milk():
corn_flakes = True
if mother.good_for_the_last_supper(breakfast):
corn_flakes = False
if not mother.knows_why_pentagon_is_big(breakfast):
corn_flakes = True
if breakfast.is_good_for_dinner():
corn_flakes = False
if mother.used_to_adored(breakfast):
corn_flakes = True
if breakfast.is_eaten_by_monk():
corn_flakes = False
if breakfast.exists_at_bottom_of_parfait():
corn_flakes = True
if breakfast.is_chinese():
corn_flakes = False
if not mother.knows_who_to_thank(breakfast):
corn_flakes = True
if not mother.corn_flakes(breakfast):
corn_flakes = False
father = Father()
print(father.predict(breakfast, corn_flakes))
$ python milkboy.py
Grilled mackerel with salt
Recommended Posts