Design Patterns: Ensure Substitutability of Subclasses using LSP

Level : Intermediate
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:25:00

Lab Details

Problem Statement:

A lab to follow the LSP principle while doing your code in C#.

  • Do refer to the below Payment class with common properties and methods.
  • Create subclasses for payment methods like CreditCard, PayPal, and CryptoCurrency.
  • Ensure that substituting one payment method for another does not disrupt the payment processing flow.

Payment Class:

public class Payment


    public string Amount { get; set; }

    public string Currency { get; set; }

    public virtual string ProcessPayment()


        // Default payment processing logic

        return "Payment processed successfully.";



Lab Objective:

Upon completion of this lab, you will be able to:

  • Understand and use the Liskov Substitution Principle (LSP) in class design.
  • Create subclasses for different payment methods ensuring substitutability.
  • Write tests to verify payment method consistency.
  • Identify and resolve any issues in payment method implementation.


You should install the following software on your machine:

  • VS Code or Visual Studio
  • .NET SDK

Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
Accept cookies & close this