Chad 8 лет назад
Родитель
Сommit
760abbf9fc
6 измененных файлов: 158 добавлений и 0 удалений
  1. Двоичные данные
      FizzBuzz.class
  2. 10
    0
      FizzBuzz.ctxt
  3. 40
    0
      FizzBuzz.java
  4. Двоичные данные
      FizzBuzzTest.class
  5. 21
    0
      FizzBuzzTest.ctxt
  6. 87
    0
      FizzBuzzTest.java

Двоичные данные
FizzBuzz.class Просмотреть файл


+ 10
- 0
FizzBuzz.ctxt Просмотреть файл

@@ -0,0 +1,10 @@
1
+#BlueJ class context
2
+comment0.target=FizzBuzz
3
+comment0.text=\n\ Write\ a\ description\ of\ class\ FizzBuzz\ here.\n\n\ @author\ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=FizzBuzz()
6
+comment1.text=\n\ Constructor\ for\ objects\ of\ class\ FizzBuzz\n
7
+comment2.params=y
8
+comment2.target=java.lang.String\ fizzbuzz(int)
9
+comment2.text=\n\ \n
10
+numComments=3

+ 40
- 0
FizzBuzz.java Просмотреть файл

@@ -0,0 +1,40 @@
1
+
2
+/**
3
+ * Write a description of class FizzBuzz here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class FizzBuzz
9
+{
10
+    // instance variables - replace the example below with your own
11
+
12
+    /**
13
+     * Constructor for objects of class FizzBuzz
14
+     */
15
+    public FizzBuzz()
16
+    {
17
+        // initialise instance variables
18
+        
19
+    }
20
+
21
+    /**
22
+     * 
23
+     */
24
+    public String fizzbuzz(int y)
25
+    {
26
+        String result = "";
27
+        if(y%3 == 0 && y%5 == 0){
28
+            result = "FizzBuzz";
29
+        }
30
+        else if(y%3 == 0){
31
+            result = "Fizz";
32
+        }else if(y%5 == 0){
33
+            result = "Buzz";
34
+        }else {
35
+        result = Integer.toString(y);
36
+    }
37
+        
38
+        return result;
39
+    }
40
+}

Двоичные данные
FizzBuzzTest.class Просмотреть файл


+ 21
- 0
FizzBuzzTest.ctxt Просмотреть файл

@@ -0,0 +1,21 @@
1
+#BlueJ class context
2
+comment0.target=FizzBuzzTest
3
+comment0.text=\n\ The\ test\ class\ FizzBuzzTest.\n\n\ @author\ \ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=FizzBuzzTest()
6
+comment1.text=\n\ Default\ constructor\ for\ test\ class\ FizzBuzzTest\n
7
+comment2.params=
8
+comment2.target=void\ setUp()
9
+comment2.text=\n\ Sets\ up\ the\ test\ fixture.\n\n\ Called\ before\ every\ test\ case\ method.\n
10
+comment3.params=
11
+comment3.target=void\ fizzbuzzTest1()
12
+comment4.params=
13
+comment4.target=void\ fizzbuzzTest2()
14
+comment5.params=
15
+comment5.target=void\ fizzbuzzTest3()
16
+comment6.params=
17
+comment6.target=void\ fizzbuzzTest4()
18
+comment7.params=
19
+comment7.target=void\ tearDown()
20
+comment7.text=\n\ Tears\ down\ the\ test\ fixture.\n\n\ Called\ after\ every\ test\ case\ method.\n
21
+numComments=8

+ 87
- 0
FizzBuzzTest.java Просмотреть файл

@@ -0,0 +1,87 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+/**
9
+ * The test class FizzBuzzTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class FizzBuzzTest
15
+{
16
+    FizzBuzz test = new FizzBuzz();
17
+    /**
18
+     * Default constructor for test class FizzBuzzTest
19
+     */
20
+    public FizzBuzzTest()
21
+    {
22
+    }
23
+
24
+    /**
25
+     * Sets up the test fixture.
26
+     *
27
+     * Called before every test case method.
28
+     */
29
+    @Before
30
+    public void setUp()
31
+    {
32
+    }
33
+    
34
+    @Test 
35
+    public void fizzbuzzTest1(){
36
+    //Given
37
+    int x = 2;
38
+    //When
39
+    String actual = test.fizzbuzz(x);
40
+    String expected = "2";
41
+    //Result
42
+    assertEquals(actual, expected);
43
+}
44
+
45
+    @Test 
46
+    public void fizzbuzzTest2(){
47
+    //Given
48
+    int x = 3;
49
+    //When
50
+    String actual = test.fizzbuzz(x);
51
+    String expected = "Fizz";
52
+    //Result
53
+    assertEquals(actual, expected);
54
+}
55
+
56
+    @Test 
57
+    public void fizzbuzzTest3(){
58
+    //Given
59
+    int x = 5;
60
+    //When
61
+    String actual = test.fizzbuzz(x);
62
+    String expected = "Buzz";
63
+    //Result
64
+    assertEquals(actual, expected);
65
+}
66
+
67
+    @Test 
68
+    public void fizzbuzzTest4(){
69
+    //Given
70
+    int x = 15;
71
+    //When
72
+    String actual = test.fizzbuzz(x);
73
+    String expected = "FizzBuzz";
74
+    //Result
75
+    assertEquals(actual, expected);
76
+}
77
+    
78
+    /**
79
+     * Tears down the test fixture.
80
+     *
81
+     * Called after every test case method.
82
+     */
83
+    @After
84
+    public void tearDown()
85
+    {
86
+    }
87
+}