Class CreditCardPaymentMethod

java.lang.Object
com.prog3.ipt.Model.PaymentMethodClasses.CreditCardPaymentMethod
All Implemented Interfaces:
PaymentMethodStrategy

public class CreditCardPaymentMethod extends Object implements PaymentMethodStrategy
CreditCardPaymentMethod is a concrete class that implements PaymentMethodStrategy interface. This class represents a credit card payment
  • Field Details

    • creditCardNumber

      private String creditCardNumber
    • creditCardExpirationDate

      private LocalDate creditCardExpirationDate
    • creditCardCVV

      private String creditCardCVV
  • Constructor Details

    • CreditCardPaymentMethod

      public CreditCardPaymentMethod(String creditCardNumber, LocalDate creditCardExpirationDate, String creditCardCVV)
      CreditCardPaymentMethod constructor
      Parameters:
      creditCardNumber - Numeric code that uniquely identifies a credit card
      creditCardExpirationDate - Credit card expiration date
      creditCardCVV - Security code consisting of 3 digits
  • Method Details

    • setCreditCardNumber

      private void setCreditCardNumber(String creditCardNumber)
    • setCreditCardExpirationDate

      private void setCreditCardExpirationDate(LocalDate creditCardExpirationDate)
    • setCreditCardCVV

      private void setCreditCardCVV(String creditCardCVV)
    • getCreditCardNumber

      public String getCreditCardNumber()
    • getCreditCardExpirationDate

      public LocalDate getCreditCardExpirationDate()
    • getCreditCardCVV

      public String getCreditCardCVV()
    • checkCreditCardNumber

      private boolean checkCreditCardNumber()
      Checks that the credit card number entered by user is correct
      Returns:
      boolean value true if card number is correct or false if not
    • checkCreditCardExpirationDate

      private boolean checkCreditCardExpirationDate()
      Checks that the credit card expiration date entered by user is valid
      Returns:
      True if card expiration date is valid or false if not
    • checkCreditCardCVV

      private boolean checkCreditCardCVV()
      Checks that the credit card CCV entered by user is valid
      Returns:
      True if card CCV is valid or false if not
    • pay

      public boolean pay(double paymentAmount)
      Makes the payment by the user
      Specified by:
      pay in interface PaymentMethodStrategy
      Parameters:
      paymentAmount - Total amount to be paid by the user
      Returns:
      True if transaction was successful or false if not
    • checkPaymentMethodData

      public boolean checkPaymentMethodData()
      Checks that the data entered by the user for the payment have been made successfully
      Specified by:
      checkPaymentMethodData in interface PaymentMethodStrategy
      Returns:
      True if data are valid or false if not
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object