Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Army Units by kurosawa4434
class job:
def __init__(self, job_name, area, name):
self.job_name = job_name
self.name = name
self.area = area
def introduce(self):
pass
class Swordsman(job):
def introduce(self):
return f'{self.job_name} {self.name}, {self.area} swordsman'
class Lancer(job):
def introduce(self):
return f'{self.job_name} {self.name}, {self.area} lancer'
class Archer(job):
def introduce(self):
return f'{self.job_name} {self.name}, {self.area} archer'
class Army:
def train_swordsman(self, name):
pass
def train_lancer(self, name):
pass
def train_archer(self, name):
pass
class AsianArmy(Army):
def __init__(self):
self.area = 'Asian'
def train_swordsman(self, name):
return Swordsman('Samurai', self.area, name)
def train_lancer(self, name):
return Lancer('Ronin', self.area, name)
def train_archer(self, name):
return Archer('Shinobi', self.area, name)
class EuropeanArmy(Army):
def __init__(self):
self.area = 'European'
def train_swordsman(self, name):
return Swordsman('Knight', self.area, name)
def train_lancer(self, name):
return Lancer('Raubritter', self.area, name)
def train_archer(self, name):
return Archer('Ranger', self.area, name)
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
my_army = EuropeanArmy()
enemy_army = AsianArmy()
soldier_1 = my_army.train_swordsman("Jaks")
soldier_2 = my_army.train_lancer("Harold")
soldier_3 = my_army.train_archer("Robin")
soldier_4 = enemy_army.train_swordsman("Kishimoto")
soldier_5 = enemy_army.train_lancer("Ayabusa")
soldier_6 = enemy_army.train_archer("Kirigae")
assert soldier_1.introduce() == "Knight Jaks, European swordsman"
assert soldier_2.introduce() == "Raubritter Harold, European lancer"
assert soldier_3.introduce() == "Ranger Robin, European archer"
assert soldier_4.introduce() == "Samurai Kishimoto, Asian swordsman"
assert soldier_5.introduce() == "Ronin Ayabusa, Asian lancer"
assert soldier_6.introduce() == "Shinobi Kirigae, Asian archer"
print("Coding complete? Let's try tests!")
June 24, 2018