Last active
August 29, 2015 14:19
-
-
Save atmb4u/fa4d779571f2fd0158e9 to your computer and use it in GitHub Desktop.
Function Pipelines with persistent State (FPS) - FPS programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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