java.lang.Object
com.prog3.ipt.Model.PaymentMethodClasses.CreditCardPaymentMethod
- All Implemented Interfaces:
PaymentMethodStrategy
CreditCardPaymentMethod is a concrete class that implements PaymentMethodStrategy interface. This class
represents a credit card payment
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreditCardPaymentMethod
(String creditCardNumber, LocalDate creditCardExpirationDate, String creditCardCVV) CreditCardPaymentMethod constructor -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
Checks that the credit card CCV entered by user is validprivate boolean
Checks that the credit card expiration date entered by user is validprivate boolean
Checks that the credit card number entered by user is correctboolean
Checks that the data entered by the user for the payment have been made successfullyboolean
int
hashCode()
boolean
pay
(double paymentAmount) Makes the payment by the userprivate void
setCreditCardCVV
(String creditCardCVV) private void
setCreditCardExpirationDate
(LocalDate creditCardExpirationDate) private void
setCreditCardNumber
(String creditCardNumber) toString()
-
Field Details
-
creditCardNumber
-
creditCardExpirationDate
-
creditCardCVV
-
-
Constructor Details
-
CreditCardPaymentMethod
public CreditCardPaymentMethod(String creditCardNumber, LocalDate creditCardExpirationDate, String creditCardCVV) CreditCardPaymentMethod constructor- Parameters:
creditCardNumber
- Numeric code that uniquely identifies a credit cardcreditCardExpirationDate
- Credit card expiration datecreditCardCVV
- Security code consisting of 3 digits
-
-
Method Details
-
setCreditCardNumber
-
setCreditCardExpirationDate
-
setCreditCardCVV
-
getCreditCardNumber
-
getCreditCardExpirationDate
-
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 interfacePaymentMethodStrategy
- 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 interfacePaymentMethodStrategy
- Returns:
- True if data are valid or false if not
-
equals
-
hashCode
public int hashCode() -
toString
-