コミット
0b3056bede

+ 35
- 0
src/main/java/com/zipcoder/payment/Check.java ファイルの表示

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 ファイルの表示

12
     public CreditCard(){
12
     public CreditCard(){
13
         ID = 1234567891;
13
         ID = 1234567891;
14
         payerName = "Tia Mowry";
14
         payerName = "Tia Mowry";
15
-        payerNumber = "4551";
15
+        payerNumber = "4551 ";
16
         expiredMonth = 10;
16
         expiredMonth = 10;
17
         expiredYear = 2019;
17
         expiredYear = 2019;
18
 
18
 
33
     }
33
     }
34
 
34
 
35
     public String getShortDescription() {
35
     public String getShortDescription() {
36
-        return null;
36
+        return "CC " + payerName + " " + payerNumber + " " + expiredMonth + "/" + expiredYear;
37
     }
37
     }
38
 
38
 
39
     public int getExpiredMonth() {
39
     public int getExpiredMonth() {
41
     }
41
     }
42
 
42
 
43
     public void setExpiredMonth(int expiredMonth) {
43
     public void setExpiredMonth(int expiredMonth) {
44
-    //this.expiredMonth = expiredMonth;
44
+    this.expiredMonth = expiredMonth;
45
     }
45
     }
46
 
46
 
47
     public void setExpiredYear(int expiredYear) {
47
     public void setExpiredYear(int expiredYear) {
51
     public int getExpiredYear() {
51
     public int getExpiredYear() {
52
         return expiredYear;
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 ファイルの表示

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 ファイルの表示

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 ファイルの表示

25
     public void getPayerName() {
25
     public void getPayerName() {
26
         //creditCard object
26
         //creditCard object
27
         CreditCard cc = new CreditCard();
27
         CreditCard cc = new CreditCard();
28
-        //long ID we are testing
28
+
29
 
29
 
30
         //Given
30
         //Given
31
         String ExpectedPayerName = "Tia Mowry";
31
         String ExpectedPayerName = "Tia Mowry";
41
         int expiredMonth = 10;
41
         int expiredMonth = 10;
42
         //creditCard object
42
         //creditCard object
43
         CreditCard cc = new CreditCard();
43
         CreditCard cc = new CreditCard();
44
-        //long ID we are testing
44
+
45
 
45
 
46
         //Given
46
         //Given
47
         int expectedExpiredMonth = expiredMonth;
47
         int expectedExpiredMonth = expiredMonth;
55
     public void getExpiredYear(){
55
     public void getExpiredYear(){
56
         //creditCard object
56
         //creditCard object
57
         CreditCard cc = new CreditCard();
57
         CreditCard cc = new CreditCard();
58
-        //long ID we are testing
58
+
59
 
59
 
60
         //Given
60
         //Given
61
         int ExpectedExpireYear = 2019;
61
         int ExpectedExpireYear = 2019;
67
     }
67
     }
68
     @Test
68
     @Test
69
     public void getShortDescription() {
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
 }