I am using Python 3 and I want to simulate a card game with my Card class below:
class Card:
def __init__(self, name = "", stars = 0, attack = 0):
self.name = name
self.stars = stars
self.attack = attack
def setName(self, name):
self.name = name
def getName(self):
return self.name
def setStars(self, stars):
self.stars = stars
def getStars(self):
return self.stars
def setAttack(self, attack):
self.attack = attack
def getAttack(self):
return self.attack
def attack(self, enemyCard):
print(self.name + "attacked" + enemyCard.getName() + "and did" + self.attack + "damage!")
The following is my driver class:
def main():
me = Card()
me.setName("Good")
me.setStars(99)
me.setAttack(9000)
you = Card()
you.setName("EVIL")
you.setStars(0)
you.setAttack(-1)
me.attack(you) <-error here
Everything works except at the very last line which is me.attack(you):
TypeError: 'int' object is not callable
I think it may have something to do with my attack method in Card but I don't quite understand why the variable you is seen as an int