Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active April 4, 2024 01:18
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 mcsee/9816f1ef8c6e05ceb9f750113471e03f to your computer and use it in GitHub Desktop.
Save mcsee/9816f1ef8c6e05ceb9f750113471e03f to your computer and use it in GitHub Desktop.
public class CreditCard {
private String cardNumber;
private int expiryMonth;
private int expiryYear;
public CreditCard(String cardNumber, int expiryMonth, int expiryYear) {
this.cardNumber = cardNumber;
this.expiryMonth = expiryMonth;
this.expiryYear = expiryYear;
// No validations on number ranges?
}
public boolean isExpired(int currentMonth, int currentYear) {
return (expiryYear < currentYear) ||
(expiryYear == currentYear && expiryMonth < currentMonth);
}
// Inappropriate intimacy code smell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment