Hi guys, I am a bit new to OOP in general, and I was just wondering if I am going around what I want to do in the right way. I am making a small game to try to learn OOP and in this game I have several classes for different creatures, I create objects from these classes and add them to lists in a class called "Active". Now I am trying to create an actively updating list of all the creatures existing.
Would this be the right way of going about doing that:
class active:
players = []
goblins = []
trolls = []
humans = []
bears = []
creaturelist = []
def updatecreaturelist(self):
for x in self.players:
self.creaturelist.append(x)
for x in self.goblins:
self.creaturelist.append(x)
for x in self.trolls:
self.creaturelist.append(x)
for x in self.humansr:
self.creaturelist.append(x)
for x in self.bears:
self.creaturelist.append(x)
Also, what exactly is the difference between a class attribute and an instance attribute?
Any help much appreciated.
Thanks,
Karl