I don't know the reason of the error that "NotImplementedError: Where is 'Swordsman'?"
Can anyone explain the reason of this error? I attached my code below.
########### Code #############
class EuropeanArmy(Army):
def train_swordsman(self, name):
return Knight(name)
def train_lancer(self, name):
return Raubritter(name)
def train_archer(self, name):
return Ranger(name)
class AsianArmy(Army):
def train_swordsman(self, name):
return Samurai(name)
def train_lancer(self, name):
return Ronin(name)
def train_archer(self, name):
return Shinobi(name)
class Knight(EuropeanArmy):
def __init__(self, name):
self.name = name
self.baseClass = 'European'
self.basicClass = 'swordsman'
def introduce(self):
result = self.__class__.__name__ + ' ' + self.name + ', ' + self.baseClass + ' ' + self.basicClass
return result
class Raubritter(EuropeanArmy):
def __init__(self, name):
self.name = name
self.baseClass = 'European'
self.basicClass = 'lancer'
def introduce(self):
result = self.__class__.__name__ + ' ' + self.name + ', ' + self.baseClass + ' ' + self.basicClass
return result
class Ranger(EuropeanArmy):
def __init__(self, name):
self.name = name
self.baseClass = 'European'
self.basicClass = 'archer'
def introduce(self):
result = self.__class__.__name__ + ' ' + self.name + ', ' + self.baseClass + ' ' + self.basicClass
return result
class Samurai(AsianArmy):
def __init__(self, name):
self.name = name
self.baseClass = 'Asian'
self.basicClass = 'swordsman'
def introduce(self):
result = self.__class__.__name__ + ' ' + self.name + ', ' + self.baseClass + ' ' + self.basicClass
return result
class Ronin(AsianArmy):
def __init__(self, name):
self.name = name
self.baseClass = 'Asian'
self.basicClass = 'lancer'
def introduce(self):
result = self.__class__.__name__ + ' ' + self.name + ', ' + self.baseClass + ' ' + self.basicClass
return result
class Shinobi(AsianArmy):
def __init__(self, name):
self.name = name
self.baseClass = 'Asian'
self.basicClass = 'archer'
def introduce(self):
result = self.__class__.__name__ + ' ' + self.name + ', ' + self.baseClass + ' ' + self.basicClass
return result
Created at: 2022/08/26 02:47; Updated at: 2022/08/30 01:30