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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreditCardPaymentMethod(String creditCardNumber, LocalDate creditCardExpirationDate, String creditCardCVV) CreditCardPaymentMethod constructor -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanChecks that the credit card CCV entered by user is validprivate booleanChecks that the credit card expiration date entered by user is validprivate booleanChecks that the credit card number entered by user is correctbooleanChecks that the data entered by the user for the payment have been made successfullybooleaninthashCode()booleanpay(double paymentAmount) Makes the payment by the userprivate voidsetCreditCardCVV(String creditCardCVV) private voidsetCreditCardExpirationDate(LocalDate creditCardExpirationDate) private voidsetCreditCardNumber(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:
payin 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:
checkPaymentMethodDatain interfacePaymentMethodStrategy- Returns:
- True if data are valid or false if not
-
equals
-
hashCode
public int hashCode() -
toString
-