Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Chocolate():
- def __init__(self, cacao_content):
- self.cacao_content = cacao_content
- @classmethod
- def sweet(cls):
- return cls(cacao_content = 30)
- @classmethod
- def semisweet(cls):
- return cls(cacao_content = 50)
- @classmethod
- def bittersweet(cls):
- return cls(cacao_content = 70)
- @classmethod
- def bitter(cls):
- return cls(cacao_content = 99)
- #Testing
- choco = Chocolate.bittersweet( )
- print(choco.cacao_content)
- milo = Chocolate.semisweet( )
- print(milo.cacao_content)
- ch = Chocolate.bitter( )
- print(ch.cacao_content)
Advertisement
Add Comment
Please, Sign In to add comment