Created
April 12, 2015 09:34
-
-
Save atmb4u/75828b874e3d20664c5f 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 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