Khalil Malik Saboor před 8 roky
rodič
revize
4dfc062fde

+ 8
- 5
src/main/java/com/zipcoder/payment/Check.java Zobrazit soubor

6
     private String routingNumber;
6
     private String routingNumber;
7
     private String accountNumber;
7
     private String accountNumber;
8
 
8
 
9
-    Check(){
10
-        ID = 1234567891;
11
-        payerName =  "Tia Mowry";
12
-        routingNumber = "34343456";
13
-        accountNumber = "***4551";
9
+
10
+
11
+    public Check(long ID, String tia_mowry, String routingNumber, String accountNumber) {
12
+
13
+    }
14
+
15
+    public Check() {
16
+
14
     }
17
     }
15
 
18
 
16
     public Long getID() {
19
     public Long getID() {

+ 3
- 2
src/main/java/com/zipcoder/payment/PaymentPresenter.java Zobrazit soubor

2
 
2
 
3
 public class PaymentPresenter {
3
 public class PaymentPresenter {
4
 
4
 
5
-
6
-
5
+    public String toString(Payment[] payments) {
6
+        return null;
7
+    }
7
 }
8
 }

+ 6
- 0
src/main/java/com/zipcoder/payment/Paypal.java Zobrazit soubor

5
     private String payerName;
5
     private String payerName;
6
     private String email;
6
     private String email;
7
 
7
 
8
+    public Paypal(long ID, String payerName, String email) {
9
+        this.ID = ID;
10
+        this.payerName = payerName;
11
+        this.email = email;
12
+    }
13
+
8
     Paypal (){
14
     Paypal (){
9
         ID = 1234567891;
15
         ID = 1234567891;
10
         email = "tia@mowry.com";
16
         email = "tia@mowry.com";

+ 5
- 5
src/test/java/com/zipcoder/payment/CheckTest.java Zobrazit soubor

87
     @Test
87
     @Test
88
     public void compareTo1(){
88
     public void compareTo1(){
89
 
89
 
90
-        int expected = 0;
91
-        int actual = cc.compareTo(cc);
90
+        int expected = 1;
91
+        int actual = ch.compareTo(cc);
92
         assertEquals(expected,actual);
92
         assertEquals(expected,actual);
93
     }
93
     }
94
     @Test
94
     @Test
95
     public void compareTo2(){
95
     public void compareTo2(){
96
 
96
 
97
         int expected = -1;
97
         int expected = -1;
98
-        int actual = cc.compareTo(ch);
98
+        int actual = ch.compareTo(pay);
99
         assertEquals(expected,actual);
99
         assertEquals(expected,actual);
100
     }
100
     }
101
     @Test
101
     @Test
102
     public void compareTo3(){
102
     public void compareTo3(){
103
 
103
 
104
-        int expected = -1;
105
-        int actual = cc.compareTo(pay);
104
+        int expected = 0;
105
+        int actual = ch.compareTo(ch);
106
         assertEquals(expected,actual);
106
         assertEquals(expected,actual);
107
     }
107
     }
108
 }
108
 }

+ 15
- 0
src/test/java/com/zipcoder/payment/CreditCardTest.java Zobrazit soubor

77
         assertEquals(expected,actual);
77
         assertEquals(expected,actual);
78
     }
78
     }
79
     @Test
79
     @Test
80
+    public void compareToAnotherCreditCard() {
81
+        int expected = 0;
82
+        cc.setPayerName("A");
83
+        cc.setNumber("1235454");
84
+
85
+        CreditCard bCreditCard = new CreditCard();
86
+        bCreditCard.setPayerName("A");
87
+        bCreditCard.setNumber("1235454");
88
+
89
+        int actual =  bCreditCard.compareTo(cc) ;
90
+
91
+        assertEquals(expected,actual);
92
+    }
93
+
94
+    @Test
80
     public void compareTo1(){
95
     public void compareTo1(){
81
 
96
 
82
         int expected = 0;
97
         int expected = 0;

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

1
 package com.zipcoder.payment;
1
 package com.zipcoder.payment;
2
 
2
 
3
+import org.junit.Test;
4
+
5
+import static junit.framework.TestCase.assertEquals;
6
+
3
 public class PaymentPresenterTest {
7
 public class PaymentPresenterTest {
8
+    @Test
9
+    public void testToString(){
10
+        Payment[] payments = new Payment[0];
11
+        PaymentPresenter presenter = new PaymentPresenter();
12
+        String expected = "";
13
+
14
+        String actual = presenter.toString(payments);
15
+
16
+        assertEquals(expected, actual);
17
+    }
18
+    @Test
19
+    public void testMultiplePayments(){
20
+        Payment[] payments = new Payment[2];
21
+        Payment Paypal = new Paypal(4L, "Tia Mowry", "tia@mowry.com");
22
+        Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551");
23
+
24
+        payment[0] = Paypal;
25
+        payment[1] = check;
26
+
27
+        PaymentPresenter presenter = new PaymentPresenter();
28
+        String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n";
29
+
30
+        String actual = presenter.toString(payments);
31
+        assertEquals(expected, actual);
32
+    }
4
 }
33
 }

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

63
     @Test
63
     @Test
64
     public void compareTo2(){
64
     public void compareTo2(){
65
 
65
 
66
-        int expected = -1;
66
+        int expected = 1;
67
         int actual = pay.compareTo(cc);
67
         int actual = pay.compareTo(cc);
68
         assertEquals(expected,actual);
68
         assertEquals(expected,actual);
69
     }
69
     }
70
     @Test
70
     @Test
71
     public void compareTo3(){
71
     public void compareTo3(){
72
 
72
 
73
-        int expected = -1;
73
+        int expected = 1;
74
         int actual = pay.compareTo(ch);
74
         int actual = pay.compareTo(ch);
75
         assertEquals(expected,actual);
75
         assertEquals(expected,actual);
76
     }
76
     }