I need to represent the payment of a customer to buy a flight ticket in an airport. The system of airport has a bonus system.
So customer can make payment for ticke
You should start with a model of the problem domain. I would expect something like the following:
This diagram states that:
Customer offers one or more Payments to a Payment ServicePayment Service accepts one or more Payments offered by a CustomerPayment has an amountPayment must be a Mileage Payment, Cash Payment, or Credit Card PaymentPaymentsTo then answer your question in terms of the solution domain, I would have your pay() method accept a collection of payments. You don't need subordinate interfaces for each kind of Payment, only various class implementations. I would use polymorphic operations to debit (if that's the right word), roll back if anything fails, and commit when all the debits succeed.