Bladeren bron

changed bonus to loop

Nhu Nguyen 6 jaren geleden
bovenliggende
commit
bd870af83b
3 gewijzigde bestanden met toevoegingen van 51 en 53 verwijderingen
  1. 1
    1
      LoopFun.java
  2. 45
    45
      LoopFunTest.java
  3. 5
    7
      README.MD

Bonus.java → LoopFun.java Bestand weergeven

@@ -1,4 +1,4 @@
1
-public class Bonus
1
+public class LoopFun
2 2
 {
3 3
 
4 4
       /**

BonusTest.java → LoopFunTest.java Bestand weergeven

@@ -5,66 +5,66 @@ import org.junit.After;
5 5
 import org.junit.Before;
6 6
 import org.junit.Test;
7 7
 
8
-public class BonusTest
8
+public class LoopFunTest
9 9
 {
10
-    private Bonus bonus;
11
-    
10
+    private LoopFun loop;
11
+
12 12
     @Before
13 13
     public void setUp(){
14
-        bonus = new Bonus();
14
+        loop = new LoopFun();
15 15
     }
16
-    
16
+
17 17
     @Test
18 18
     public void testFactorialBase(){
19 19
         //Given
20 20
         int number = 1;
21 21
         int expected = 1;
22
-        
22
+
23 23
         //When
24
-        int actual = bonus.factorial(number);
25
-        
24
+        int actual = loop.factorial(number);
25
+
26 26
         //Then
27 27
         assertEquals(expected, actual);
28
-        
28
+
29 29
     }
30
-        
30
+
31 31
     @Test
32 32
     public void testFactorialOfSmallNumber(){
33 33
         //Given
34 34
         int number = 3;
35 35
         int expected = 6;
36
-        
36
+
37 37
         //When
38
-        int actual = bonus.factorial(number);
39
-        
38
+        int actual = loop.factorial(number);
39
+
40 40
         //Then
41 41
         assertEquals(expected, actual);
42
-        
42
+
43 43
     }
44
-    
44
+
45 45
     @Test
46 46
     public void testFactorialOfBigNumber(){
47 47
         //Given
48 48
         int number = 6;
49 49
         int expected = 720;
50
-        
50
+
51 51
         //When
52
-        int actual = bonus.factorial(number);
53
-        
52
+        int actual = loop.factorial(number);
53
+
54 54
         //Then
55 55
         assertEquals(expected, actual);
56
-        
56
+
57 57
     }
58
-    
58
+
59 59
     @Test
60 60
     public void testAcronymBasic() {
61 61
         //Given
62 62
         String phrase = "Portable Network Graphics";
63 63
         String expected = "PNG";
64
-        
64
+
65 65
         //When
66
-        String actual = bonus.acronym(phrase);
67
-        
66
+        String actual = loop.acronym(phrase);
67
+
68 68
         //Then
69 69
         assertEquals(expected, actual);
70 70
     }
@@ -74,10 +74,10 @@ public class BonusTest
74 74
         //Given
75 75
         String phrase = "Ruby on Rails";
76 76
         String expected = "ROR";
77
-        
77
+
78 78
         //When
79
-        String actual = bonus.acronym(phrase);
80
-        
79
+        String actual = loop.acronym(phrase);
80
+
81 81
         //Then
82 82
         assertEquals(expected, actual);
83 83
     }
@@ -87,10 +87,10 @@ public class BonusTest
87 87
         //Given
88 88
         String phrase = "First In, First Out";
89 89
         String expected = "FIFO";
90
-        
90
+
91 91
         //When
92
-        String actual = bonus.acronym(phrase);
93
-        
92
+        String actual = loop.acronym(phrase);
93
+
94 94
         //Then
95 95
         assertEquals(expected, actual);
96 96
     }
@@ -100,43 +100,43 @@ public class BonusTest
100 100
         //Given
101 101
         String phrase = "GNU Image Manipulation Program";
102 102
         String expected = "GIMP";
103
-        
103
+
104 104
         //When
105
-        String actual = bonus.acronym(phrase);
106
-        
105
+        String actual = loop.acronym(phrase);
106
+
107 107
         //Then
108 108
         assertEquals(expected, actual);
109 109
     }
110
-    
111
-    
112
-    
113
-    
110
+
111
+
112
+
113
+
114 114
     @Test
115 115
     public void testEncryptWithTheFirstAlphabet(){
116 116
         //Given
117 117
         String word = "apple";
118 118
         String expected = "dssoh";
119
-        
119
+
120 120
         //When
121
-        String actual = bonus.encrypt(word);
122
-        
121
+        String actual = loop.encrypt(word);
122
+
123 123
         //Then
124 124
         assertEquals(expected, actual);
125 125
     }
126
-    
126
+
127 127
     @Test
128 128
     public void testEncryptWithTheLastLetters(){
129 129
         //Given
130 130
         String word = "wxyz";
131 131
         String expected = "zabc";
132
-        
132
+
133 133
         //When
134
-        String actual = bonus.encrypt(word);
135
-        
134
+        String actual = loop.encrypt(word);
135
+
136 136
         //Then
137 137
         assertEquals(expected, actual);
138 138
     }
139
-    
140
-    
139
+
140
+
141 141
 
142 142
 }

+ 5
- 7
README.MD Bestand weergeven

@@ -1,6 +1,5 @@
1 1
 # Quiz 1
2
-You have one hour to complete this quiz. You are required to do section 1 & 2. 
3
-Section 3 is a bonus section, which means do it if you finish the other two sections before the hour is up.
2
+You have two hours to complete this quiz. Make sure your code compile when you submit the PR!
4 3
 
5 4
 ### **Instructions:**
6 5
 
@@ -30,11 +29,10 @@ Make all the tests in the `StringUtilitiesTest` class pass. All the methods have
30 29
   - `String removeCharacter(String value, char charToRemove)`
31 30
   - `String getLastWord(String value)`
32 31
 
33
-## Section 3 - Bonus
34
-This section is optional, but highly encourage you to complete. 
35
-Make all the tests in the `BonusTest` class pass. All the methods have been stubbed 
36
-out for you in the `Bonus` class. 
37
-Each of the method has a comment above it to describe the expected behavior. 
32
+## Section 3 - LoopFun
33
+Make all the tests in the `LoopFunTest` class pass. All the methods have been stubbed
34
+out for you in the `LoopFun` class.
35
+Each of the method has a comment above it to describe the expected behavior.
38 36
 Look at the test case to see example of input and expected output.
39 37
 
40 38
   - `int factorial(int number)`