Quellcode durchsuchen

improve string representation for abstract_factory

Sakis Kasampalis vor 12 Jahren
Ursprung
Commit
f603e3f5d4
1 geänderte Dateien mit 11 neuen und 0 gelöschten Zeilen
  1. 11 0
      abstract_factory.py

+ 11 - 0
abstract_factory.py

@@ -14,6 +14,17 @@ class PetShop:
 
         self.pet_factory = animal_factory
 
+
+    def show_pet(self):
+        """Creates and shows a pet using the
+        abstract factory"""
+
+        pet = self.pet_factory.get_pet()
+        print("This is a lovely {}".format(pet))
+        print("It says {}".format(pet.speak()))
+        print("It eats {}".format(self.pet_factory.get_food()))
+
+
     def show_pet(self):
         """Creates and shows a pet using the
         abstract factory"""