|
|
před 8 roky | |
|---|---|---|
| src | před 8 roky | |
| .gitignore | před 8 roky | |
| README.MD | před 8 roky | |
| pom.xml | před 8 roky |
Comparable interfacecom.zipcoder.payment.Payment interface
getId() method which returns a LonggetPayerName() method which returns a StringgetShortDescription method which returns a Stringcom.zipcoder.payment.CreditCardTest test classcom.zipcoder.payment.CreditCard class which implements the com.zipcoder.payment.Payment interfacegetShortDescription to return CC [payerName] [last 4 digit of the number] [expiredMonth]/[expiredYear]
CC Tia Mowry 4551 10/2019CheckTest test classCheck class which implements the com.zipcoder.payment.Payment interfacegetShortDescription to return Check [payerName] ***[last 4 digit of the account]
Check Tia Mowry ***4551PayPalTest test classPayPal class which implements the com.zipcoder.payment.Payment interfacegetShortDescription to return Paypal [payerName] [email]
Paypal Tia Mowry tia@mowry.comNote: You may use the String/Long compareTo methods in your code
com.zipcoder.payment.Payment class to extends the Comparable interface
public class com.zipcoder.payment.Payment extends Comparable<com.zipcoder.payment.Payment>compareTo method. Compare using the getShortDescription()
Paypal Tia Mowry tia@mowry.com and a Check with the short description of Check Tia Mowry ***4551, then the compareTo method should return a number larger than 0compareTo method will return number larger than 0 if this payment comes after payment2compareTo method will return number 0 if this payment has the same informationcompareTo method will return number less than 0 if this payment comes before payment2PaymentSortByPayer class which implements java.util.Comparator
public class PaymentSortByPayer implements Comparator<com.zipcoder.payment.Payment>compare method from the Comparatorcompare method will return number larger than 0 if payment1 comes after payment2compare method will return number 0 if the payment has the same informationcompare method will return number less than 0 if payment1 comes before payment2PaymentPresenterTestCreate a test case to test the toString method of the PaymentPresenter class
com.zipcoder.payment.Payment[] payments = new com.zipcoder.payment.Payment[0];
PaymentPresenter presenter = new PaymentPresenter();
String expected = "";
String actual = presenter.toString(payments);
assertEquals(expected, actual);
com.zipcoder.payment.Payment[] payments = new com.zipcoder.payment.Payment[2];
com.zipcoder.payment.Payment paypal = new PayPayl(4L, "Tia Mowry", "tia@mowry.com");
com.zipcoder.payment.Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
payment[0] = paypal;
PaymentPresenter presenter = new PaymentPresenter();
String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n";
String actual = presenter.toString(payments);
assertEquals(expected, actual);
Create a test case to test the toStringByPayerName method of the PaymentPresenter class
PaymentSortByPayer class to sort, then build the string using the short description com.zipcoder.payment.Payment[] payments = new com.zipcoder.payment.Payment[2];
com.zipcoder.payment.Payment paypal = new PayPayl(4L, "Tamara Mowry", "tamara@mowry.com");
com.zipcoder.payment.Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
payment[0] = paypal;
PaymentPresenter presenter = new PaymentPresenter();
String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
String actual = presenter.toString(payments);
assertEquals(expected, actual);
Create a test case to test the toStringById method of the PaymentPresenter class
com.zipcoder.payment.Payment[] payments = new com.zipcoder.payment.Payment[2];
com.zipcoder.payment.Payment paypal = new PayPayl(120L, "Tamara Mowry", "tamara@mowry.com");
com.zipcoder.payment.Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
payment[0] = paypal;
PaymentPresenter presenter = new PaymentPresenter();
String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
String actual = presenter.toString(payments);
assertEquals(expected, actual);