Question: Explain if the code given is following open and close principle or not.If it follows, open and close principle explain how.If it does not, rewrite
Explain if the code given is following open and close principle or not.If it follows, open and close principle explain how.If it does not, rewrite the code and explain.You can choose any language. Python or java.Pythonclass PaymentProcessor:def processpaymentself paymenttype:if paymenttype "CreditCard":self.processcreditcardelif paymenttype "PayPal":self.processpaypall# Add more elif clauses for each new payment methoddef processcreditcardself:printProcessing credit card payment..."def processpaypalself:printProcessing PayPal payment..."
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
