Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class IceCream :
- def __init__(self, type, num):
- self.type = type
- self.num = num
- self.flavors = []
- def add(self, flavor):
- if len(self.flavors) < self.num :
- self.flavors.append(flavor)
- else :
- pass
- def have(self,flavor):
- return self.flavors.count(flavor)
- #Main Program
- ic = IceCream('Cone',3)
- ic.add('Strawberry')
- ic.add('Chocolate')
- ic.add('Strawberry')
- ic.add('Vanilla')
- print(ic.have('Strawberry'))
- print(ic.have('Vanilla'))
Advertisement
Add Comment
Please, Sign In to add comment