0
MAC端子が...位置引数OSX
from enemy import Enemy
random_monster = Enemy("Basic enemy", 12, 1)
print(random_monster)
random_monster.take_damage(4)
print(random_monster)
をtake_damageメソッドに2つの位置引数を渡すイムを言うと、他のファイルはここにある______________________
class Enemy:
def __init__(self, name="Enemy", hit_points = 0, lives = 1):
self.name = name
self.hit_points = hit_points
self.lives = lives
def take_damage(damage):
remaining_points = self.hit_points - take_damage
if remaining_points >= 0:
self.hit_points = remaining_points
print("i took {} damage and have {} left".format(damage, self.hit_points))
else:
self.lives -= 1
def __str__(self):
return "Name: {0.name}, Lives: {0.lives}, Hitpoints: {0.hit_points}".format(self)
ああ、あなたに感謝しました!私も被害の代わりにtake_damageを差し引こうとしました。愚かな学習ミス笑 – KeatonBenning