Implementing Interfaces

Implementing Interfaces
πŸ‘¨β€πŸ’Ό Let's build a payment system with different payment methods. We'll use interfaces to ensure all payment methods follow the same contract.
🐨 Open
index.ts
and:
  1. Create a PaymentMethod interface with a pay(amount: number) method
  2. Create a CreditCard class that implements PaymentMethod
  3. Create a PayPal class that implements PaymentMethod
  4. Each class should have its own implementation of pay()
πŸ’° Classes that implement an interface must define all its methods.

Please set the playground first

Loading "Implementing Interfaces"
Loading "Implementing Interfaces"