Jason Gibbs eeaba2302b finishing up# | 6 lat temu | |
---|---|---|
src | 6 lat temu | |
.DS_Store | 6 lat temu | |
.gitignore | 6 lat temu | |
README.MD | 6 lat temu | |
pom.xml | 6 lat temu |
Comparable
interfacePayment
interface
getId()
method which returns a LonggetPayerName()
method which returns a StringgetShortDescription
method which returns a StringCreditCardTest
test classCreditCard
class which implements the Payment
interfacegetShortDescription
to return CC [payerName] [last 4 digit of the number] [expiredMonth]/[expiredYear]
CC Tia Mowry 4551 10/2019
CheckTest
test classCheck
class which implements the Payment
interfacegetShortDescription
to return Check [payerName] ***[last 4 digit of the account]
Check Tia Mowry ***4551
PayPalTest
test classPayPal
class which implements the Payment
interfacegetShortDescription
to return Paypal [payerName] [email]
Paypal Tia Mowry tia@mowry.com
Note: You may use the String/Long compareTo methods in your code
Payment
class to extends the Comparable interface
public interface Payment extends Comparable<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<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 payment2PaymentPresenterTest
Create a test case to test the toString
method of the PaymentPresenter class
Payment[] payments = new Payment[0];
PaymentPresenter presenter = new PaymentPresenter();
String expected = "";
String actual = presenter.toString(payments);
assertEquals(expected, actual);
Payment[] payments = new Payment[2];
Payment paypal = new PayPayl(4L, "Tia Mowry", "tia@mowry.com");
Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
payment[0] = paypal;
payment[1] = check;
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 Payment[] payments = new Payment[2];
Payment paypal = new PayPayl(4L, "Tamara Mowry", "tamara@mowry.com");
Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
payment[0] = paypal;
payment[1] = check;
PaymentPresenter presenter = new PaymentPresenter();
String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
String actual = presenter.toStringByPayerName(payments);
assertEquals(expected, actual);
Create a test case to test the toStringById
method of the PaymentPresenter class
Payment[] payments = new Payment[2];
Payment paypal = new PayPayl(120L, "Tamara Mowry", "tamara@mowry.com");
Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
payment[0] = paypal;
payment[1] = check;
PaymentPresenter presenter = new PaymentPresenter();
String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
String actual = presenter.toStringById(payments);
assertEquals(expected, actual);