Implement a class Payment
and then define child classes CreditCardPayment
, DebitCardPayment
, NetBankingPayment
, each with a unique method transactionProcess
that returns the process of the respective payment methods.
Example 1:
Input: CreditCardPayment Output: "CreditCardPayment: Verify the credit card details, authorize the transaction and deduct the amount."
Example 2:
Input: NetBankingPayment Output: "NetBankingPayment: Validate the customer’s net banking credentials, authorize the transaction and debit the amount."
Implement a method transactionProcess
in each of the child classes that returns the respective process of the payment methods.
class Payment: def transactionProcess(self): pass class CreditCardPayment(Payment): def transactionProcess(self): return "CreditCardPayment: Verify the credit card details, authorize the transaction and deduct the amount." class DebitCardPayment(Payment): def transactionProcess(self): return "DebitCardPayment: Verify the debit card details, authorize the transaction and deduct the amount." class NetBankingPayment(Payment): def transactionProcess(self): return "NetBankingPayment: Validate the customer’s net banking credentials, authorize the transaction and debit the amount." # Test the classes credit_card_payment = CreditCardPayment() print(credit_card_payment.transactionProcess()) debit_card_payment = DebitCardPayment() print(debit_card_payment.transactionProcess()) net_banking_payment = NetBankingPayment() print(net_banking_payment.transactionProcess())
Unlock AI & Data Science treasures. Log in!