Browse Source

changed bonus to loop

Nhu Nguyen 6 years ago
parent
commit
bd870af83b
3 changed files with 51 additions and 53 deletions
  1. 1
    1
      LoopFun.java
  2. 45
    45
      LoopFunTest.java
  3. 5
    7
      README.MD

Bonus.java → LoopFun.java View File

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

BonusTest.java → LoopFunTest.java View File

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

+ 5
- 7
README.MD View File

1
 # Quiz 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
 ### **Instructions:**
4
 ### **Instructions:**
6
 
5
 
30
   - `String removeCharacter(String value, char charToRemove)`
29
   - `String removeCharacter(String value, char charToRemove)`
31
   - `String getLastWord(String value)`
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
 Look at the test case to see example of input and expected output.
36
 Look at the test case to see example of input and expected output.
39
 
37
 
40
   - `int factorial(int number)`
38
   - `int factorial(int number)`