I'm trying to get the program to take the hp stat from enemyUnit
, the attack stat from unit
, and the damage stat from tackle
and put them into one math problem in the method getHit()
. this is the code:
class Pokemon(object): def __init__(self,hp,attack,defence):self.hp = hpself.attack = attackself.defence = defencedef getHit(self,damage,hp,attack):self.hp -= damage * self.attack/self.defenceprint str(self.hp)class Move(object):def __init__(self,damage):self.damage = damageunit = Pokemon(10,2,3)
enemyUnit = Pokemon(4,2,3)
tackle = Move(3)enemyUnit.getHit(enemyUnit,tackle,unit)
unfortunately it gives me the error
unsupported operand type(s) for *: 'Pokemon' and 'int'
how do I get it to take all the variables from all instances of each class and put them into one function?