I am new to Java. I have CardDetails class which is a return type of my getCardDetails method. Now, the scenario is I have common class(CardDetails) to return a result to my UI from method getCardDetails().
public class CardDetails {
String cardNumber;
String cardCode;
String cardStatus;
String debitCardPrimaryAccountNumber;
String creditCardDescription;
String creditCardActionCode;
}
If you see the class last fields creditCardDescription and creditCardActionCode are of credit card & debitCardPrimaryAccountNumber is only specific to DebitCard. Now, which concept of OOPs I can use so that in case of Credit Card my class object would be:
public class CardDetails {
String cardNumber;
String cardCode;
String cardStatus;
String creditCardDescription;
String creditCardActionCode;
}
and for Debit card it would be:
public class CardDetails {
String cardNumber;
String cardCode;
String cardStatus;
String debitCardPrimaryAccountNumber;
}
As my return type would always be CardDetails class.
Thanks in advance !