SHARE
TWEET

Untitled

a guest Oct 10th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Product:
  2.     def produce(self):
  3.         pass
  4.     def sell(self):
  5.         pass
  6.  
  7. class House(Product):
  8.     def produce(self):
  9.         print("House produce...")
  10.     def sell(self):
  11.         print("House sell...")
  12.  
  13. class Clothes(Product):
  14.     def produce(self):
  15.         print("Clothes produce...")
  16.     def sell(self):
  17.         print("Clothes sell...")
  18.  
  19. class IPod(Product):
  20.     def produce(self):
  21.         print("IPod produce...")
  22.     def sell(self):
  23.         print("IPod sell...")
  24.  
  25. class Crop:
  26.     def __init__(self, product):
  27.         self.product = product
  28.     def makeMoney(self):
  29.         self.product.produce()
  30.         self.product.sell()
  31.  
  32. class HouseCrop(Crop):
  33.     def __init__(self, house):
  34.         super().__init__(house)
  35.  
  36. class ShanZhaiCrop(Crop):
  37.     def __init__(self, product):
  38.         super().__init__(product)
  39.  
  40. def client():
  41.     house = House()
  42.     houseCrop = HouseCrop(house)
  43.     houseCrop.makeMoney()
  44.  
  45.     sz = ShanZhaiCrop(IPod())
  46.     sz.makeMoney()
  47.     sz = ShanZhaiCrop(Clothes())
  48.     sz.makeMoney()
  49.  
  50. if __name__ == "__main__":
  51.     client()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top