python初心者です。
自分とボスのステータスを出力したいプログラムを作成したのですが、以下のようなエラー発生していまいます。
ご教授お願いします。
import random class character(): def _init_(self): self.name="" self.HP=0 self.AT=0 def SetAbility(self): self.name=input() self.HP = 50+random.randint(1,20) self.AT = 8+random.randint(1,5) def GetAbility(self): print('あなたの名前は{}です'.format(self.name)) print('あなたの体力は{}です'.format(self.HP)) print('あなたの攻撃力は{}です'.format(self.AT)) class enemy(character): def BossAbility(self): self.BHP=self.HP+100 self.BAT=self.AT+10 def BGetBAbility(self): print('ボスの体力は{}です'.format(self.BHP)) print('ボスの攻撃力は{}です'.format(self.BAT)) a=character() a.SetAbility() a.GetAbility() b=enemy() b.BossAbility() b.BGetBAbility()
AttributeError:'enemy' object has no attribute 'HP'
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/15 02:29