I am practicing classes and subclasses in Python. I'm not sure whether it might be useful to add a subclass to the following code, instead of just adding methods to the class.
# Practice with classes
class ElixerTroops(object):
def __init__(self, name, dps, life, special):
self.name = name
self.dps = dps
self.life = life
self.special = special
barbarian = ElixerTroops("barbarian ", 23.00 , 95.0, "none")
archer = ElixerTroops("archer ", 20.00 , 40.0, "shoots arrows")
dragon = ElixerTroops("dragon ", 180.0 , 2300, "flies")
print "Troop: " + barbarian.name
print "Damage: " + str(barbarian.dps)
print "Life: " + str(barbarian.life)
print "Special Abilities: " + barbarian.special
troops = [barbarian, archer]
troops.append(dragon)
for i in troops:
print "Name:", i.name, "Damage:", i.dps, "Life:", i.life, "Special Abilities:", i.special
Could I have made this code simpler to read?