Je n'ai pas pu m'empêcher de l'écrire car j'ai été frappé par le fait que la répétition de "~ yanai" et "~ chau yanai" était facile à incorporer dans le branchement conditionnel des langages de programmation (?).
Est-ce comme ça si vous souhaitez reproduire le matériau de flocon de maïs?
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 "Maquereau grillé au sel"
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
Maquereau grillé au sel
Recommended Posts