jpsp91 пре 8 година
родитељ
комит
68a7a79c7b
7 измењених фајлова са 223 додато и 1 уклоњено
  1. BIN
      FizzBuzz.class
  2. 13
    0
      FizzBuzz.ctxt
  3. 92
    0
      FizzBuzz.java
  4. BIN
      FizzBuzzTest.class
  5. 11
    0
      FizzBuzzTest.ctxt
  6. 66
    0
      FizzBuzzTest.java
  7. 41
    1
      package.bluej

+ 13
- 0
FizzBuzz.ctxt Прегледај датотеку

@@ -0,0 +1,13 @@
1
+#BlueJ class context
2
+comment0.target=FizzBuzz
3
+comment1.params=
4
+comment1.target=FizzBuzz()
5
+comment2.params=input
6
+comment2.target=java.lang.String\ fizz(int)
7
+comment3.params=input
8
+comment3.target=java.lang.String\ buzz(int)
9
+comment4.params=input
10
+comment4.target=java.lang.String\ fizzbuzz(int)
11
+comment5.params=input
12
+comment5.target=java.lang.String\ nonFizzbuzz(int)
13
+numComments=6

+ 92
- 0
FizzBuzz.java Прегледај датотеку

@@ -0,0 +1,92 @@
1
+//import java.util.Scanner;
2
+public class FizzBuzz
3
+{
4
+    public FizzBuzz()
5
+    {
6
+        
7
+    }
8
+    
9
+    public String fizz(int input)
10
+    {
11
+        String result = "";
12
+        
13
+        if(input % 3 == 0){
14
+            result = "Fizz";
15
+        }
16
+        
17
+        return result;
18
+    }
19
+    
20
+    public String buzz (int input){
21
+        String result = "";
22
+        
23
+        if(input % 5 == 0){
24
+            result = "Buzz";
25
+        }
26
+        
27
+        return result;
28
+    }
29
+    
30
+    public String fizzbuzz(int input){
31
+        String result = "";
32
+     
33
+        if(input % 3 == 0 && input % 5 == 0){
34
+            result = "FizzBuzz";
35
+        }
36
+        
37
+        return result;
38
+    }
39
+    
40
+    public String nonFizzbuzz(int input){
41
+        String result = "";
42
+        
43
+        if(input % 3 == 0){
44
+            result = "Fizz";
45
+        }
46
+        else if(input % 5 == 0){
47
+            result = "Buzz";
48
+        }
49
+        else if(input % 3 == 0 && input % 5 == 0){
50
+            result = "FizzBuzz";
51
+        }
52
+        else{
53
+            result = String.valueOf(input);
54
+        }
55
+        
56
+        return result;
57
+    }
58
+}
59
+    
60
+    
61
+    
62
+    
63
+    
64
+    
65
+    
66
+    
67
+    
68
+    
69
+    
70
+    
71
+    
72
+    
73
+    
74
+    
75
+    
76
+    
77
+    
78
+    
79
+    
80
+    
81
+    
82
+    
83
+    
84
+    
85
+    
86
+    
87
+    
88
+    
89
+    
90
+    
91
+    
92
+

BIN
FizzBuzzTest.class Прегледај датотеку


+ 11
- 0
FizzBuzzTest.ctxt Прегледај датотеку

@@ -0,0 +1,11 @@
1
+#BlueJ class context
2
+comment0.target=FizzBuzzTest
3
+comment1.params=
4
+comment1.target=void\ fizzTest()
5
+comment2.params=
6
+comment2.target=void\ buzzTest()
7
+comment3.params=
8
+comment3.target=void\ fizzbuzzTest()
9
+comment4.params=
10
+comment4.target=void\ nonFizzbuzzTest()
11
+numComments=5

+ 66
- 0
FizzBuzzTest.java Прегледај датотеку

@@ -0,0 +1,66 @@
1
+import static org.junit.Assert.*;
2
+import org.junit.After;
3
+import org.junit.Before;
4
+import org.junit.Test;
5
+import org.junit.Assert;
6
+
7
+public class FizzBuzzTest
8
+{
9
+    FizzBuzz fb = new FizzBuzz();
10
+    
11
+    @Test
12
+    public void fizzTest()
13
+    {
14
+        //expected
15
+        String expected = "Fizz";
16
+        
17
+        //actual
18
+        String actual = fb.fizz(3);
19
+        
20
+        Assert.assertEquals(expected, actual);
21
+    }
22
+    
23
+    @Test
24
+    public void buzzTest()
25
+    {
26
+        //expected
27
+        String expected = "Buzz";
28
+        
29
+        //actual
30
+        String actual = fb.buzz(5);
31
+        
32
+        Assert.assertEquals(expected, actual);
33
+    }
34
+    
35
+    @Test
36
+    public void fizzbuzzTest()
37
+    {
38
+        //expected
39
+        String expected = "FizzBuzz";
40
+        
41
+        //actual
42
+        String actual = fb.fizzbuzz(15);
43
+        
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+    
47
+    @Test
48
+    public void nonFizzbuzzTest()
49
+    {
50
+        //expected
51
+        String expected = "2";
52
+        
53
+        //actual
54
+        String actual = fb.nonFizzbuzz(2);
55
+        
56
+        Assert.assertEquals(expected, actual);
57
+    }
58
+    
59
+    
60
+    
61
+    
62
+    
63
+    
64
+    
65
+    
66
+}

+ 41
- 1
package.bluej Прегледај датотеку

@@ -1,3 +1,43 @@
1 1
 #BlueJ package file
2
-#Thu May 31 13:04:16 EDT 2018
2
+dependency1.from=FizzBuzzTest
3
+dependency1.to=FizzBuzz
4
+dependency1.type=UsesDependency
5
+editor.fx.0.height=1057
6
+editor.fx.0.width=1920
7
+editor.fx.0.x=-282
8
+editor.fx.0.y=-1057
9
+objectbench.height=101
10
+objectbench.width=461
11
+package.divider.horizontal=0.6
12
+package.divider.vertical=0.8007380073800738
13
+package.editor.height=427
14
+package.editor.width=674
15
+package.editor.x=277
16
+package.editor.y=23
17
+package.frame.height=600
18
+package.frame.width=800
19
+package.numDependencies=1
20
+package.numTargets=2
21
+package.showExtends=true
22
+package.showUses=true
3 23
 project.charset=UTF-8
24
+readme.height=58
25
+readme.name=@README
26
+readme.width=47
27
+readme.x=10
28
+readme.y=10
29
+target1.association=FizzBuzzTest
30
+target1.height=50
31
+target1.name=FizzBuzz
32
+target1.showInterface=false
33
+target1.type=ClassTarget
34
+target1.width=80
35
+target1.x=250
36
+target1.y=130
37
+target2.height=50
38
+target2.name=FizzBuzzTest
39
+target2.showInterface=false
40
+target2.type=UnitTestTargetJunit4
41
+target2.width=80
42
+target2.x=280
43
+target2.y=100