Add design pattern code - factory method.