Blessing988

Untitled

Mar 29th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. class Chocolate():
  2.  
  3.     def __init__(self, cacao_content):
  4.         self.cacao_content = cacao_content
  5.  
  6.     @classmethod
  7.     def sweet(cls):
  8.         return cls(cacao_content = 30)
  9.  
  10.     @classmethod
  11.     def semisweet(cls):
  12.         return cls(cacao_content = 50)
  13.  
  14.     @classmethod
  15.     def bittersweet(cls):
  16.         return cls(cacao_content = 70)
  17.  
  18.     @classmethod
  19.     def bitter(cls):
  20.         return cls(cacao_content = 99)
  21.  
  22. #Testing
  23.  
  24. choco = Chocolate.bittersweet( )
  25. print(choco.cacao_content)
  26.  
  27. milo = Chocolate.semisweet( )
  28. print(milo.cacao_content)
  29.  
  30. ch = Chocolate.bitter( )
  31. print(ch.cacao_content)
Advertisement
Add Comment
Please, Sign In to add comment