ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 파이썬 개발일지 #001
    파이썬 일지 2021. 12. 14. 12:17
    class Monster():
        hp = 100
        alive = True
    
        def damage(self, attack):
            self.hp = self.hp - attack
            if self.hp < 0:
                self.alive = False
        def status_check(self):
            if self.alive == True:
                print('살았다!')
            else:
                print('죽었다!')
    
    
    
    m1 = Monster()
    m1.damage(150)
    m1.status_check()
    
    
    m2 = Monster()
    m2.damage(80)
    m2.status_check()
Designed by Tistory.