## ## # ## # # ## # # # ## # # # # ## # # # # # ## # # # # # # # def f(b) :# # # # # # # # global h# # # # # # # # for i in range(len(h)) :# # # # # # # # if(h[i]>=b) :# # # # # # # # return i+1# # # # # # # # return len(h)+1# # # # # # # # a=int(input())# # # # # # # # h=list(map(int,input().split()))# # # # # # # # b=int(input())# # # # # # # # print(f(b))# # # # # # ## # # # # ## # # # ## # # ## # ## ### class student :# def speak(self):# print("I'm ",self.name," I'm",self.age,"years old")# def __init__(self,name,age):# self.name=name# self.age=age# a=student('Taei',10)# b=student('JS',100)# a.speak()# b.speak()# class Person :# def speak(self):# print("I'm ",self.name," I'm",self.age,"years old")# def __init__(self,name,age):# self.name=name# self.age=age# class student(Person):# def __init__(self,a,b,c):# super(). __init__(a,b)# self.grade=c# def speak(self):# print("I'm student")# super().speak()# def study(self):# print ('read a book')# a=student("Taei",10,5)# a.speak()# name ='보병'# hp=40# damage = 5# print("{} 유닛을 생성했습니다.".format(name))# print("체력 {0}, 공격력 {1}\n".format(hp, damage))## tank_name='탱크'# tank_hp = 150# tank_damage = 35# print("{} 유닛을 생성했습니다.".format(tank_name))# print("체력 {0}, 공격력 {1}\n".format(tank_hp, tank_damage))## tank2_name = "탱크"# tank2_hp = 150# tank2_damage = 35# print("{} 유닛을 생성했습니다.".format(tank2_name))# print("체력 {0}, 공격력 {1}\n".format(tank2_hp, tank2_damage))# def attack(name, location, damage) :# print("{0} : {1} 방향 적군을 공격합니다. [공격력 {2}]".format(name,location,damage))# attack(name, "1시", damage)# attack(tank_name, "1시", tank_damage)# attack(tank2_name, "1시", tank2_damage)class Unit: def __init__(self, name, hp,speed): self.name = name self.hp = hp self.speed = speed print("{0} 유닛을 생성했습니다.".format(name)) def move(self, location): print("{0} : {1} 방향으로 이동합니다. [속도 {2}]".format(self.name, location,self.speed)) 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)# soldier3 = Unit("보병",40,5)# stealth1 = Unit("전투기",80,5)# print("유닛이름 : {0}, 공격력 : {1}".format(stealth1.name, stealth1.damage))# stealth2=Unit("업그레이드한 전투기", 80, 5)# stealth2.cloaking = True# if stealth2.cloaking == True:# print("{0}는 현재 은폐 상태입니다.".format(stealth2.name))class AttackUnit(Unit): def __init__(self, name, hp, damage,speed): Unit.__init__(self,name, hp,speed) self.damage = damage def attack(self, location): print("{0} : {1} 방향 적군을 공격합니다. [공격력 {2}]".format(self.name, location, self.damage))# flamethrower1 = AttackUnit("화염방사병", 50, 16)# flamethrower1.attack("5시")# flamethrower1.damaged(25)# flamethrower1.damaged(25)class Flyable: def __init__(self, flying_speed): self.flying_speed = flying_speed def fly(self, name, location): print("{0} : {1} 방향으로 날아갑니다. [속도 {2}]" \ .format(name, location, self.flying_speed))class FlyableAttackUnit(AttackUnit,Flyable): def __init__(self, name, hp, damage, flying_speed): AttackUnit.__init__(self, name, hp, damage,0) Flyable.__init__(self, flying_speed) def move(self, location): # Unit 클래스의 move() 메서드를 오버라이딩 print("[공중 유닛 이동]") self.fly(self.name, location)# interceptor = FlyableAttackUnit("요격기",200,6,5)# interceptor.fly(interceptor.name, "3시")hoverbike = AttackUnit("호버 바이크", 80, 20, 10)spacecruiser = FlyableAttackUnit("우주 순양함", 500, 25, 3)hoverbike.move("11시")spacecruiser.move("9시")class BuildingUnit(Unit): def __init__(self, name, hp, location): Unit.__init__(self, name, hp, 0) super().__init__(name, hp, 0) self.location = location pass def game_start(): print("[알림] 새로운 게임을 시작합니다.") def game_over(): pass game_start() game_over()supply_depot = BuildingUnit("보급고", 500, "7시")class Soldier(AttackUnit): def __init__(self): AttackUnit.__init__(self,"보병",40,5,1) def booster(self): if self.hp > 10: self.hp -= 10 # 체력 10 소모 print("{0} : 강화제를 사용합니다. (HP 10 감소)".format(self.name)) else: print("{0} : 체력이 부족해 기술을 사용할 수 없습니다".format(self.name)) https: // thebook.io / 0 80357 / 0370 /top of page

실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
827
827
댓글 0개
좋아요
댓글(0)
더 이상 게시물에 대한 댓글 기능이 지원되지 않습니다. 자세한 사항은 사이트 소유자에게 문의하세요.
bottom of page


