Khalil Malik Saboor před 8 roky
rodič
revize
93333fe901

+ 13
- 1
src/main/java/com/zipcoder/payment/PaymentPresenter.java Zobrazit soubor

1
 package com.zipcoder.payment;
1
 package com.zipcoder.payment;
2
 
2
 
3
+import java.util.Arrays;
4
+
3
 public class PaymentPresenter {
5
 public class PaymentPresenter {
4
 
6
 
5
     public String toString(Payment[] payments) {
7
     public String toString(Payment[] payments) {
6
-        return null;
8
+        Arrays.sort(payments);
9
+        StringBuilder sb = new StringBuilder();
10
+        for (Payment o: payments) {
11
+            o.getID();
12
+            o.getPayerName();
13
+
14
+            sb.append(o.getShortDescription()+"\n");
15
+        }
16
+        return sb.toString();
7
     }
17
     }
18
+
19
+
8
 }
20
 }

+ 2
- 2
src/test/java/com/zipcoder/payment/PaymentPresenterTest.java Zobrazit soubor

21
         Payment Paypal = new Paypal(4L, "Tia Mowry", "tia@mowry.com");
21
         Payment Paypal = new Paypal(4L, "Tia Mowry", "tia@mowry.com");
22
         Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551");
22
         Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551");
23
 
23
 
24
-        payment[0] = Paypal;
25
-        payment[1] = check;
24
+        payments[0] = Paypal;
25
+        payments[1] = check;
26
 
26
 
27
         PaymentPresenter presenter = new PaymentPresenter();
27
         PaymentPresenter presenter = new PaymentPresenter();
28
         String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n";
28
         String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n";