class Car():
def init(self,name):
self.name=name
class Benc():
def init(self,name):
self.name=name
class Carfactorty():
def makecar(name):
if name==‘宝马’:
return Car(name)
elif name==‘奔驰’:
return Benc(name)
car=Carfactorty.makecar(‘宝马’)
print(car.name)
car2=Carfactorty.makecar(‘奔驰’)
print(car2.name)