강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

WB J님의 프로필 이미지
WB J

작성한 질문수

파이썬 무료 강의 (기본편) - 6시간 뒤면 나도 개발자

메소드

오류관련

작성

·

240

0

class Unit:
    def __init__(self,name,hp,damage):
        self.name=name
        self.hp=hp
        self.damage=damage
        print('{0} 유닛이 생성 되었습니다.'.format(self.name))
        print('체력 {0}, 공격력 {1}'.format(self.hp,self.damage))
       
 

class AttackUnit:
    def __init__(self,name,hp,damage):
        self.name=name
        self.hp=hp
        self.damage=damage
       
    def attack(self,location):
        print('{0} : {1} 방향으로 적군을 공격 합니다. [공격력 {2}'\
            .format(self.name,location,self.damage))
       
    def damaged(self,damage):
        print('{0} : {1} 데미지를 입었습니다.'.format(self.name,damage))
        self.hp-=damage
        print('{0} : 현재 체력은 {1} 입니다.'.format(self.name,self.hp))
        if self.hp<=0:
            print('{0} : 파괴되었습니다.'.format(self.name))
           
    firebat1 = AttackUnit("파이어뱃",50,16)!!!!!
    firebat1.attack('5시')
   
    firebat1.damaged(25)
    firebat1.damaged(25)
 
느낌표 있는 줄에서 AttackUnit이 정의되지 않았다고 뜹니다...
 
 

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
WB J님의 프로필 이미지
WB J

작성한 질문수

질문하기