我为每种付款方式开设了课程,例如Cash
,,。我必须根据对象值将对象作为参数传递,我必须实例化一个相关类。Cheque
Card
我怎样才能做到这一点?给我一个更好的设计
public interface CollectionInfo {
//Code Goes here
}
public class Cash implements CollectionInfo {
//Code goes here
}
public class CollectionFactory {
public void newInstance(Enum<CollectionMode> collectionMode) {
}
}
public interface Receipts {
public Receipt createReceipt(String Amount, /*(Here i need to pass parameter of object either cash ,Cheque or card),*/Date date);
}