| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package com.zipcoder.payment;
-
- public class Check implements Payment {
-
- /*
- Create a `Check` class which implements the `Payment` interface
- 3. Add the required methods from the interface
- 4. Add getter and setter test for an id
- - Add a Long id field
- - Add a getter and setter method to make the test pass
- 5. Repeat step 4 for the following fields:
- - String payerName
- - String routing number
- - String accountNumber
- 6. Implement the `getShortDescription` to return `Check [payerName] ***[last 4 digit of the account]`
- - ex: `Check Tia Mowry ***4551`
- 7. You may create any type of constructor or methods that will with this lab
-
- */
-
- long id;
- String payerName;
-
- String routingNumber;
- String accountNumber;
-
-
- public Check() {
- }
-
- public Check(long id, String payerName, String routingNumber, String accountNumber) {
- this.id = id;
- this.payerName = payerName;
- this.routingNumber = routingNumber;
- this.accountNumber = accountNumber;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getpayerName() {
- return payerName;
- }
-
- public void setPayerName(String payerName) {
- this.payerName = payerName;
- }
-
- public String getRoutingNumber() {
- return routingNumber;
- }
-
- public void setRoutingNumber(String routingNumber) {
- this.routingNumber = routingNumber;
- }
-
- public String getAccountNumber() {
- return accountNumber;
- }
-
- public void setAccountNumber(String accountNumber) {
- this.accountNumber = accountNumber;
- }
- public String getLastfourAccountNumber() {
- String str = "";
- String acctNo = this.accountNumber.toString();
- if (acctNo.length() > 4) {
- str = acctNo.substring(acctNo.length() - 4);
- } else {
- str = acctNo;
- }
-
- return str;
-
- }
- @Override
-
- public String getShortDescription() {
- return "Check " + this.payerName + " ***" + this.getLastfourAccountNumber() ;
- }
-
-
- @Override
- public int compareTo(Payment other) {
- return this.getShortDescription() .compareTo(other.getShortDescription() );
-
- }
- }
|