# 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))
#
# 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))
#
# class Soldier(AttackUnit) :
# def __init__(self):
# AttackUnit.__init__(self, "보병", 40, 5, 1)
#
# def booster(self):
# if self.hp > 10 :
# self.hp -= 10
# print("{0} : 강화제를 사용합니다. (HP 10 감소)".format(self.name))
# else :
# print("{0} : 체력이 부족해 기술을 사용할 수 없습니다".format(self.name))
#
# class Tank(AttackUnit) :
# siege_developed = False
#
# def __init__(self):
# AttackUnit.__init__(self, "탱크", 150, 35, 1)
# self.siege_mode = False
#
# def set_siege_mode(self):
# if Tank.siege_developed == False:
# return
# if self.siege_mode == False:
# print("{0} : 시지 모드로 전환합니다.".format(self.name))
# self.damage *= 2
# self.siege_mode = True
# else:
# print("{0} : 시지 모드를 해제합니다.".format(self.name))
# self.damage //= 2
# self.siege_mode = False
#
#
# 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):
# self.fly(self.name, location)
#
# class Stealth(FlyableAttackUnit):
# def __init__(self):
# FlyableAttackUnit.__init__(self, "전투기", 80, 20, 5)
# self.cloaked = False
#
# def cloaking(self):
# if self.cloaked == True:
# print("{0} : 은폐 모드를 해제합니다.".format(self.name))
# self.cloaked = False
# else:
# print("{0} : 은폐 모드를 설정합니다.".format(self.name))
# self.cloaked = True
#
# class BuildingUnit(Unit) :
# def __init__(self, name, hp, location):
# Unit.__init__(self, name, hp, 0)
# super().__init__(name, hp, 0)
# self.location = location
#
# def game_start():
# print("[알림] 새로운 게임을 시작합니다.")
#
# def game_over():
# print("Player : Good Game")
# print("[Player] 님이 게임에서 퇴장했습니다.")
#
# game_start()
#
# so1 = Soldier()
# so2 = Soldier()
# so3 = Soldier()
#
# ta1 = Tank()
# ta2 = Tank()
#
# st1 = Stealth()
#
# attack_units = []
# attack_units.append(so1)
# attack_units.append(so2)
# attack_units.append(so3)
# attack_units.append(ta1)
# attack_units.append(ta2)
# attack_units.append(st1)
#
# for unit in attack_units:
# unit.move("1시")
#
# Tank.siege_developed = True
# print("[알림] 탱크의 시지 모드 개발이 완료됐습니다.")
#
# for unit in attack_units:
# if isinstance(unit, Soldier):
# unit.booster()
# elif isinstance(unit, Tank):
# unit.set_siege_mode()
# elif isinstance(unit, Stealth):
# unit.cloaking()
#
# for unit in attack_units:
# unit.attack("1시")
#
# from random import *
#
# for unit in attack_units:
# unit.attack("1시")
#
# for unit in attack_units:
# unit.damaged(randint(5, 20))
#
# game_over()
class House:
def __init__(self, location, house_type, deal_type, price, completion_year):
self.location = location
self.house_type = house_type
self.deal_type = deal_type
self.price = price
self.completion_year = completion_year
def show_detail(self):
print(self.location, self.house_type, self.deal_type, \
self.price, self.completion_year)
houses = []
house1 = House("강남", "아파트", "매매", "10억 원", "2010년")
house2 = House("마포", "오피스텔", "전세", "5억 원", "2007년")
house3 = House("송파", "빌라", "월세", "500/50만 원", "2000년")
houses.append(house1)
houses.append(house2)
houses.append(house3)
print("총 {0}가지 매물이 있습니다.".format(len(houses)))
for house in houses:
house.show_detail()top of page

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


