Skip to content

Instantly share code, notes, and snippets.

@atmb4u
Created April 12, 2015 09:34
Show Gist options
  • Save atmb4u/75828b874e3d20664c5f to your computer and use it in GitHub Desktop.
Save atmb4u/75828b874e3d20664c5f to your computer and use it in GitHub Desktop.
Function Pipelines with persistent State (FPS) - FPS programming
class WaterBottle(object):
def __init__(self):
self.water = 100
self.max_capacity = 500
self.make = "Plastic"
def add_water(self, amount):
if self.max_capacity < self.water + amount:
self.water = self.max_capacity
print "OverFlow"
else:
self.water += amount
print self.water
def drink_water(self, amount):
if amount > self.water:
self.water = 0
print "Finish"
else:
self.water -= amount
print self.water
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment