Skip to content

Instantly share code, notes, and snippets.

@danveloper
Last active December 12, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danveloper/4760263 to your computer and use it in GitHub Desktop.
Save danveloper/4760263 to your computer and use it in GitHub Desktop.
public interface PaymentMethod {
enum PaymentMethodType {
GIFT_CARD, CREDIT_CARD
}
PaymentMethodType getType();
}
public class GiftCard implements PaymentMethod {
String number;
BigDecimal balance;
@Override
public PaymentMethodType getType() {
return PaymentMethod.PaymentMethodType.GIFT_CARD;
}
}
public class CreditCard implements PaymentMethod {
String number;
Date expiration;
Address billingAddress;
@Override
public PaymentMethodType getType() {
return PaymentMethod.PaymentMethodType.CREDIT_CARD;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment