Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
20-liner: Swordsman, Lancer & Archer Are all Soldiers solution in Clear category for Army Units by Stensen
from abc import ABCMeta, abstractmethod
from dataclasses import make_dataclass
class Army(metaclass=ABCMeta):
@abstractmethod
def train_swordsman(self, name): raise NotImplementedError
@abstractmethod
def train_lancer(self, name): raise NotImplementedError
@abstractmethod
def train_archer(self, name): raise NotImplementedError
class EuropeanArmy(Army):
train_swordsman = lambda self, name: Swordsman(name, 'Knight', 'European', 'swordsman')
train_lancer = lambda self, name: Lancer(name, 'Raubritter', 'European', 'lancer')
train_archer = lambda self, name: Archer(name, 'Ranger', 'European', 'archer')
class AsianArmy(Army):
train_swordsman = lambda self, name: Swordsman(name, 'Samurai', 'Asian', 'swordsman')
train_lancer = lambda self, name: Lancer(name, 'Ronin', 'Asian', 'lancer')
train_archer = lambda self, name: Archer(name, 'Shinobi', 'Asian', 'archer')
Soldier = make_dataclass('Soldier', ['name', 'type', 'army_type', 'soldier'],
namespace={'introduce': lambda self: f'{self.type} {self.name}, {self.army_type} {self.soldier}'})
Swordsman = Lancer = Archer = Soldier
Oct. 15, 2020