import random
import numpy as np
np.set_printoptions(suppress=True)
gladList = np.empty((128,5))
class Gladiators:
def __init__(self,name1,hp,atd,armor,accuracy):
self.name1=name1
self.hp=hp
self.atd=atd
self.armor=armor
self.accuracy=accuracy
@staticmethod
def createRobot(x):
for i in range(x):
gladList[i]=(i,random.randint(1000,1500),random.randint(40,80),random.randint(0,100),random.randint(60,100))
print(gladList[i])
def info(self):
print("Analyzing Gladiator...")
print("Name:",self.name1,"Health:",self.hp,"AD:",self.atd,"Armor:",self.armor,"Accuracy:",self.accuracy)
def isAlive(self):
pass
def fight(self):
pass
Gladiators.createRobot(128) g1=gladList[41] ig1=Gladiators.info(g1) print(ig1)
> Error: line 27, in info
print("Name:",self.name1,"Health:",self.hp,"AD:",self.atd,"Armor:",self.armor,"Accuracy:",self.accuracy)
AttributeError: 'numpy.ndarray' object has no attribute 'name1'
>
I guess i should use self instead of using static method but im still getting error anyways
Aucun commentaire:
Enregistrer un commentaire