[나도코딩 파이썬 기본편] #9 클래스 Class 따라하기
1, 2. 클래스와 init class Unit: def __init__(self, name, hp, damage): self.name = name self.hp = hp self.damage = damage print("{} 유닛이 생성되었습니다." .format(self.name)) print("체력 {}, 공격력 {}" .format(self.hp, self.damage)) marine = Unit("마린", 40, 5) tank = Unit("탱크", 150, 35) __init__ : 객체의 생성자 / self를 제외하고 객체(marine, tank)의 유닛(name, hp, damage)과 동일하게 만들어야 한다 3. 멤버변수 wraith1 = Unit("레이스", 80, 5) print("유..
2022.02.02