top of page

소스 코드 제출

공개·회원 52명

20250817




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))


soldier1 = Unit("보병", 40, 5)
soldier2 = Unit("보병", 40, 5)
tank = Unit("탱크", 150, 35)
stealth1=Unit("전투기", 80, 5)
stealth2=Unit("업그레이드한 전투기", 80, 5)
stealth2.cloaking = True




print("유닛 이름 : {0}, 공격력 : {1}". format(stealth1.name, stealth1.damage))

if stealth2.cloaking == True :
    print("{0}는 현재 은폐 상태 상태입니다.".format(stealth2.name))


flamethrower1=AttackUnit("화염방사병", 50, 16)
flamethrower1.attack("5시")

flamethrower1.damaged(25)
flamethrower1.damaged(25)





3회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page