Created
March 25, 2015 03:56
-
-
Save letuananh/3845288a361064d4a437 to your computer and use it in GitHub Desktop.
Demo code - Adopted from http://pastebin.com/duV5fwGh
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 sys | |
| class Player: | |
| def __init__(self, name, age): | |
| self.lives = 10 | |
| self.name = name | |
| self.age = age | |
| def eat(self, food): | |
| if food == "apple": | |
| self.health -= 10 | |
| elif food == "banana": | |
| self.health += 10 | |
| def introduce(self): | |
| print("I'm %s and I'm %s year(s) old." % (self.name, self.age)) | |
| #----------------------------------------- | |
| name = raw_input("What is your name? ") | |
| age = raw_input("How old are you? ") | |
| player1 = Player(name, age) | |
| player1.introduce() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment