Khalil Malik Saboor 8 jaren geleden
bovenliggende
commit
0b3056bede

+ 35
- 0
src/main/java/com/zipcoder/payment/Check.java Bestand weergeven

@@ -0,0 +1,35 @@
1
+package com.zipcoder.payment;
2
+
3
+public class Check implements Payment {
4
+    private long ID;
5
+    private String payerName;
6
+    private String routingNumber;
7
+    private String accountNumber;
8
+    public Long getID() {
9
+        return ID;
10
+    }
11
+
12
+    public String getPayerName() {
13
+        return payerName;
14
+    }
15
+
16
+    public String getShortDescription() {
17
+        return null;
18
+    }
19
+
20
+    public void setID(long ID) {
21
+        this.ID = ID;
22
+    }
23
+
24
+    public void setPayerName(String payerName) {
25
+        this.payerName = payerName;
26
+    }
27
+
28
+    public void setRoutingNumber(String routingNumber) {
29
+    this.routingNumber = routingNumber;
30
+    }
31
+
32
+    public String getRoutingNumber() {
33
+        return routingNumber;
34
+    }
35
+}

+ 7
- 3
src/main/java/com/zipcoder/payment/CreditCard.java Bestand weergeven

@@ -12,7 +12,7 @@ public class CreditCard implements Payment {
12 12
     public CreditCard(){
13 13
         ID = 1234567891;
14 14
         payerName = "Tia Mowry";
15
-        payerNumber = "4551";
15
+        payerNumber = "4551 ";
16 16
         expiredMonth = 10;
17 17
         expiredYear = 2019;
18 18
 
@@ -33,7 +33,7 @@ public class CreditCard implements Payment {
33 33
     }
34 34
 
35 35
     public String getShortDescription() {
36
-        return null;
36
+        return "CC " + payerName + " " + payerNumber + " " + expiredMonth + "/" + expiredYear;
37 37
     }
38 38
 
39 39
     public int getExpiredMonth() {
@@ -41,7 +41,7 @@ public class CreditCard implements Payment {
41 41
     }
42 42
 
43 43
     public void setExpiredMonth(int expiredMonth) {
44
-    //this.expiredMonth = expiredMonth;
44
+    this.expiredMonth = expiredMonth;
45 45
     }
46 46
 
47 47
     public void setExpiredYear(int expiredYear) {
@@ -51,4 +51,8 @@ public class CreditCard implements Payment {
51 51
     public int getExpiredYear() {
52 52
         return expiredYear;
53 53
     }
54
+
55
+    public void setNumber(String number) {
56
+        this.number = this.number;
57
+    }
54 58
 }

+ 15
- 0
src/main/java/com/zipcoder/payment/Paypal.java Bestand weergeven

@@ -0,0 +1,15 @@
1
+package com.zipcoder.payment;
2
+
3
+public class Paypal implements Payment {
4
+    public Long getID() {
5
+        return null;
6
+    }
7
+
8
+    public String getPayerName() {
9
+        return null;
10
+    }
11
+
12
+    public String getShortDescription() {
13
+        return null;
14
+    }
15
+}

+ 49
- 0
src/test/java/com/zipcoder/payment/CheckTest.java Bestand weergeven

@@ -0,0 +1,49 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.*;
6
+
7
+public class CheckTest {
8
+
9
+    @Test
10
+    public void getID() {
11
+        //creditCard object
12
+        Check check = new Check();
13
+        //long ID we are testing
14
+
15
+        //Given
16
+        long ExpectedID = 1234567891;
17
+        //When
18
+        check.setID(ExpectedID);
19
+        //Then
20
+        long actualID = check.getID();
21
+        assertEquals(ExpectedID,actualID);
22
+    }
23
+
24
+    @Test
25
+    public void getPayerName() {
26
+        //creditCard object
27
+        Check check = new Check();
28
+
29
+
30
+        //Given
31
+        String ExpectedPayerName = "Tia Mowry";
32
+        //When
33
+        check.setPayerName(ExpectedPayerName);
34
+        //Then
35
+        String actualID = check.getPayerName();
36
+        assertEquals(ExpectedPayerName,actualID);
37
+    }
38
+    @Test
39
+    public void testRoutingNumber(){
40
+        Check check = new Check();
41
+
42
+        String routingNumber = "00124556";
43
+
44
+        check.setRoutingNumber(routingNumber);
45
+
46
+        String actual = check.getRoutingNumber();
47
+        assertEquals(routingNumber,actual);
48
+    }
49
+}

+ 16
- 3
src/test/java/com/zipcoder/payment/CreditCardTest.java Bestand weergeven

@@ -25,7 +25,7 @@ public class CreditCardTest {
25 25
     public void getPayerName() {
26 26
         //creditCard object
27 27
         CreditCard cc = new CreditCard();
28
-        //long ID we are testing
28
+
29 29
 
30 30
         //Given
31 31
         String ExpectedPayerName = "Tia Mowry";
@@ -41,7 +41,7 @@ public class CreditCardTest {
41 41
         int expiredMonth = 10;
42 42
         //creditCard object
43 43
         CreditCard cc = new CreditCard();
44
-        //long ID we are testing
44
+
45 45
 
46 46
         //Given
47 47
         int expectedExpiredMonth = expiredMonth;
@@ -55,7 +55,7 @@ public class CreditCardTest {
55 55
     public void getExpiredYear(){
56 56
         //creditCard object
57 57
         CreditCard cc = new CreditCard();
58
-        //long ID we are testing
58
+
59 59
 
60 60
         //Given
61 61
         int ExpectedExpireYear = 2019;
@@ -67,6 +67,19 @@ public class CreditCardTest {
67 67
     }
68 68
     @Test
69 69
     public void getShortDescription() {
70
+        CreditCard cc = new CreditCard();
71
+
72
+        String payerName = "Khalil Saboor ";
73
+        int expiredMonth = 12;
74
+        int expiredYear = 2020;
75
+        String payerNumber = " 4551 ";
76
+        cc.setPayerName(payerName);
77
+        cc.setExpiredMonth(expiredMonth);
78
+        cc.setExpiredYear(expiredYear);
79
+        cc.setNumber(payerNumber);
70 80
 
81
+        String expected = "CC " + payerName + " " + payerNumber + "  " + expiredMonth + "/" + expiredYear;
82
+        System.out.println(cc.getShortDescription());
83
+        String actual = cc.getShortDescription();
71 84
     }
72 85
 }