瀏覽代碼

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 年之前
父節點
當前提交
760d693ce1
共有 1 個文件被更改,包括 9 次插入9 次删除
  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
 # ====================