De'Jon Johnson 6 anos atrás
pai
commit
f1b933c68e
5 arquivos alterados com 79 adições e 1 exclusões
  1. BIN
      .DS_Store
  2. BIN
      src/.DS_Store
  3. BIN
      src/main/.DS_Store
  4. 17
    1
      src/main/java/FizzBuzz.java
  5. 62
    0
      src/test/java/FizzBuzzTest.java

BIN
.DS_Store Ver arquivo


BIN
src/.DS_Store Ver arquivo


BIN
src/main/.DS_Store Ver arquivo


+ 17
- 1
src/main/java/FizzBuzz.java Ver arquivo

@@ -1,2 +1,18 @@
1
+
1 2
 public class FizzBuzz {
2
-}
3
+
4
+
5
+    public String of(int num) {
6
+        if (num % 15 == 0) {
7
+            return "FizzBuzz";
8
+
9
+        } else if (num % 5 == 0) {
10
+                return "Buzz";
11
+            } else if (num % 3 == 0){
12
+            return "Fizz";
13
+        } else {
14
+                return String.valueOf(num);
15
+            }
16
+
17
+        }
18
+    }

+ 62
- 0
src/test/java/FizzBuzzTest.java Ver arquivo

@@ -1,2 +1,64 @@
1
+import org.junit.Assert;
2
+import org.junit.Test;
3
+
1 4
 public class FizzBuzzTest {
5
+
6
+@Test
7
+public void testFifteen() {
8
+
9
+    //Given
10
+
11
+    FizzBuzz liftUp = new FizzBuzz();
12
+    String differentWord = "FizzBuzz";
13
+
14
+    //When
15
+    String awesome = liftUp.of(15);
16
+    Assert.assertEquals(differentWord, awesome);
17
+
18
+
19
+
2 20
 }
21
+@Test
22
+    public void testFive() {
23
+
24
+        //Given
25
+
26
+        FizzBuzz FitBit = new FizzBuzz();
27
+        String newWord = "Buzz";
28
+
29
+        //When
30
+        String hamburger = FitBit.of(5);
31
+        Assert.assertEquals(newWord, hamburger);
32
+
33
+    }
34
+
35
+
36
+@Test
37
+public void testThree() {
38
+
39
+    //Given
40
+    FizzBuzz Fizzbuzz = new FizzBuzz();
41
+    String expWord = "Fizz";
42
+
43
+    //When
44
+    String actWord = Fizzbuzz.of(3);
45
+
46
+    Assert.assertEquals(expWord, actWord );
47
+
48
+    }
49
+    @Test
50
+    public void numberAsString() {
51
+
52
+        //Given
53
+
54
+        FizzBuzz nooo = new FizzBuzz();
55
+        String differentWord = "4";
56
+
57
+        //When
58
+        String hello = nooo.of(4);
59
+        Assert.assertEquals(differentWord, hello);
60
+
61
+    }
62
+
63
+}
64
+