Skip to content

Instantly share code, notes, and snippets.

@letuananh
Created March 25, 2015 03:56
Show Gist options
  • Save letuananh/3845288a361064d4a437 to your computer and use it in GitHub Desktop.
Save letuananh/3845288a361064d4a437 to your computer and use it in GitHub Desktop.

Revisions

  1. letuananh created this gist Mar 25, 2015.
    22 changes: 22 additions & 0 deletions player.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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()