Check.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.zipcoder.payment;
  2. public class Check implements Payment {
  3. Long id;
  4. String payerName;
  5. String routingName;
  6. String accountNumber;
  7. public Check(){}
  8. public Check(Long id, String payerName, String routingName, String accountNumber){
  9. this.id = id;
  10. this.payerName = payerName;
  11. this.routingName = routingName;
  12. this.accountNumber = accountNumber;
  13. }
  14. public Check(String payerName, String accountNumber){
  15. this.payerName = payerName;
  16. this.accountNumber = accountNumber;
  17. }
  18. public Long getID() {
  19. return id;
  20. }
  21. public void setID(Long id) {
  22. this.id = id;
  23. }
  24. public String getPayerName() {
  25. return payerName;
  26. }
  27. public void setPayerName(String payerName){
  28. this.payerName = payerName;
  29. }
  30. public String getRoutingName() {
  31. return routingName;
  32. }
  33. public void setRoutingName(String routingName) {
  34. this.routingName = routingName;
  35. }
  36. public String getAccountNumber() {
  37. return accountNumber;
  38. }
  39. public void setAccountNumber(String accountNumber) {
  40. this.accountNumber = accountNumber;
  41. }
  42. public String getShortDescription() {
  43. return ("Check " + getPayerName() + " ***" + getLastFourDigits());
  44. }
  45. public String getLastFourDigits(){
  46. String lastFour = accountNumber.substring(accountNumber.length()-4);
  47. return lastFour;
  48. }
  49. public int compareTo(Payment o) {
  50. return this.getShortDescription().compareTo(o.getShortDescription());
  51. }
  52. }