Strategy Pattern Lab 1

Objective:

Add a gift card payment option to the existing strategy pattern implementation:

Assignment: Implement Gift Card Payment Strategy

You have been given an existing shopping cart (code in Demo section) implementation that uses the Strategy pattern for payment processing. The current implementation supports credit card and PayPal payment strategies. Your task is to extend the system to include a new payment strategy: the Gift Card payment strategy.

Requirements:

  1. Implement a new class called GiftCardStrategy that implements the PaymentStrategy interface.

  2. The GiftCardStrategy class should have the following attributes:

    • cardNumber (String): The gift card number.

    • pin (String): The PIN for the gift card.

  3. Implement the pay() method in the GiftCardStrategy class. The method should output a message stating that the payment amount has been deducted from the gift card balance.

Note:

  • You can assume that the existing classes (CreditCardStrategy, PayPalStrategy, and ShoppingCart) are already implemented correctly. You can use the existing code in the previous example as a starting point for your implementation.