Skip to content

Instantly share code, notes, and snippets.

@atmb4u
Last active August 29, 2015 14:19
Show Gist options
  • Save atmb4u/fa4d779571f2fd0158e9 to your computer and use it in GitHub Desktop.
Save atmb4u/fa4d779571f2fd0158e9 to your computer and use it in GitHub Desktop.
Function Pipelines with persistent State (FPS) - FPS programming
class Bottle(object):
def __init__(self):
self.liquid = 100
self.name = ""
self.max_capacity = 500
self.make = "Plastic"
def print_details(bottle):
print bottle.liquid, bottle.name, bottle.max_capacity, bottle.make
def name_bottle(bottle, name):
bottle.name = name
def fill(bottle, amount):
if bottle.max_capacity < bottle.liquid + amount:
print "Overflow"
else:
bottle.liquid += amount
print bottle.liquid
def drink(bottle, amount):
if amount > bottle.liquid:
print "Finish"
else:
bottle.liquid -= amount
print bottle.liquid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment