Instantiate particular class based on object value

I have classes for each payment mode for e.g. Cash, Cheque, Card. I have to pass object as a parameter based on object value I have to instantiate a relevant class.

How can I achieve this? Suggest me a better design

You could pass an enumeration (Cash/Cheque/Card) into a factory ?


and within that method you would do:

where CashPayment, ChequePayment etc. are subclasses of Payment.