Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short solution in Clear category for Army Units by Phil15
class Soldier:
def __init__(self, name, army, title):
self.name, self.army, self.title = name, army, title
def introduce(self):
return f"{self.title} {self.name}, {self.army} {self.army_type}"
class Swordsman(Soldier):army_type = 'swordsman'
class Lancer(Soldier):army_type = 'lancer'
class Archer(Soldier):army_type = 'archer'
class Army:
def train_swordsman(self, name):
return Swordsman(name, self.nation, self.swordsman)
def train_lancer(self, name):
return Lancer(name, self.nation, self.lancer)
def train_archer(self, name):
return Archer(name, self.nation, self.archer)
class AsianArmy(Army):
nation, swordsman, lancer, archer = 'Asian', 'Samurai', 'Ronin', 'Shinobi'
class EuropeanArmy(Army):
nation, swordsman, lancer, archer = 'European', 'Knight', 'Raubritter', 'Ranger'
Aug. 13, 2018