| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package com.zipcoder.payment;
-
- public class CreditCard implements Payment {
- private long id;
- private String payerName;
- private String number;
- private int expiredMonth;
- private int expiredYear;
-
- public CreditCard(long id, String payerName, String number, int expiredMonth, int expiredYear) {
- this.id = id;
- this.payerName = payerName;
- this.number = number;
- this.expiredMonth = expiredMonth;
- this.expiredYear = expiredYear;
-
- }
- public long getId() {
- return id;
- }
- public String getPayerName() {
- return payerName;
- }
- public String getNumber() {
- return number;
- }
- public int getExpiredMonth() {
- return expiredMonth;
- }
- public int getExpiredYear() {
- return expiredYear;
- }
-
- public String getShortDescription(){
- return String.format("CC %s %s %d/%d", payerName, number.substring(number.length() - 4, number.length()), expiredMonth, expiredYear);
- }
-
- public int compareTo(Payment p) {
- return this.getShortDescription().compareTo(p.getShortDescription());
- }
-
- }
|