Jelajahi Sumber

Small change in output : Methods of factory should print 'We have...' since they are the once only producing the object', object specific methods can start from 'It is ...'

Arovit Narula 11 tahun lalu
induk
melakukan
760d693ce1
1 mengubah file dengan 9 tambahan dan 9 penghapusan
  1. 9 9
      abstract_factory.py

+ 9 - 9
abstract_factory.py

@@ -23,9 +23,9 @@ class PetShop:
         abstract factory"""
 
         pet = self.pet_factory.get_pet()
-        print("This is a lovely {}".format(pet))
+        print("We have a lovely {}".format(pet))
         print("It says {}".format(pet.speak()))
-        print("It eats {}".format(self.pet_factory.get_food()))
+        print("We also have {}".format(self.pet_factory.get_food()))
 
 
 # Stuff that our factory makes
@@ -83,15 +83,15 @@ if __name__ == "__main__":
         print("=" * 20)
 
 ### OUTPUT ###
-# This is a lovely Dog
+# We have a lovely Dog
 # It says woof
-# It eats dog food
+# We also have dog food
 # ====================
-# This is a lovely Cat
-# It says meow
-# It eats cat food
+# We have a lovely Dog
+# It says woof
+# We also have dog food
 # ====================
-# This is a lovely Dog
+# We have a lovely Dog
 # It says woof
-# It eats dog food
+# We also have dog food
 # ====================