Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Character(object):
- def __init__(self, hp, hp_max):
- self.hp = hp
- self.hp_max = hp_max
- def got_hit(self):
- self.hp -= 5
- print(self.hp)
- def heal(self):
- if self.hp + 10 <= self.hp_max:
- self.hp += 10
- print(self.hp)
- char = Character(50, 100)
- char.got_hit() # 45
- char.heal() # 55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement