#sample solution
def run(bottle):
#your code here
bottle.drink(250)
bottle.refill(150)
return bottle.amount_left
class Bottle:
def __init__(self, liquid):
self.amount= 500
self.height = 10
self.empty = False
self.liquid = liquid
def amount_left(self):
return self.amount
def drink(self, amount):
if amount < self.amount:
self.amount -= amount
elif amount == self.amount:
self.amount -= amount
self.empty = True
else:
print "Cannot drink more " + self.liquid + " than there is!"
def refill(self, amount):
if amount + self.amount > 500:
print "Cannot add that much " + self.liquid + " to the bottle!"
else:
self.amount += amount
self.empty = False
No comments:
Post a Comment