Created
July 9, 2011 16:32
-
-
Save paulbarbu/1073719 to your computer and use it in GitHub Desktop.
Python Kitty
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
import kitty_class | |
def main(): | |
jerry = kitty_class.Kitty("jerry") | |
jerry.watchCat() | |
jerry.nameCat("jerrard") | |
jerry.feedCat() | |
jerry.watchCat() | |
if __name__ == "__main__": | |
main() |
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 Kitty(object): | |
"""Kitty blueprint.""" | |
def __init__(self, name): | |
self.name = name | |
self.__play = False | |
self.__eating = False | |
def playCat(self): | |
self.__play = not self.__play | |
def feedCat(self): | |
self.__eating = not self.__eating | |
def nameCat(self, name): | |
self.name = name | |
def watchCat(self): | |
print "{0} playing: {1}".format(self.name, self.__play) | |
print "{0} eating: {1}".format(self.name, self.__eating) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment