Ich konnte nicht anders, als es zu schreiben, weil mir aufgefallen ist, dass die wiederholten "~ yanai" und "~ chau yanai" leicht in die bedingte Verzweigung der Programmiersprache (?) Zu integrieren waren.
Ist es so, wenn Sie das Cornflakes-Material reproduzieren möchten?
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 "Gegrillte Makrele mit Salz"
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
Gegrillte Makrele mit Salz
Recommended Posts