Rachelle 8 lat temu
rodzic
commit
55cf84e247
8 zmienionych plików z 132 dodań i 1 usunięć
  1. BIN
      .DS_Store
  2. BIN
      FizzBuzz.class
  3. 9
    0
      FizzBuzz.ctxt
  4. 31
    0
      FizzBuzz.java
  5. BIN
      FizzBuzzTest.class
  6. 14
    0
      FizzBuzzTest.ctxt
  7. 41
    0
      FizzBuzzTest.java
  8. 37
    1
      package.bluej

BIN
.DS_Store Wyświetl plik


BIN
FizzBuzz.class Wyświetl plik


+ 9
- 0
FizzBuzz.ctxt Wyświetl plik

@@ -0,0 +1,9 @@
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=number
8
+comment2.target=java.lang.String\ answer(int)
9
+numComments=3

+ 31
- 0
FizzBuzz.java Wyświetl plik

@@ -0,0 +1,31 @@
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
+
11
+    /**
12
+     * Constructor for objects of class FizzBuzz
13
+     */
14
+    public FizzBuzz()
15
+    {
16
+
17
+    }
18
+
19
+    public String answer(int number){
20
+        if((number%3==0) && (number%5==0)){
21
+            return "fizzbuzz";
22
+        }else if(number%3==0){
23
+            return "fizz";
24
+        }else if(number%5==0){
25
+            return "buzz";
26
+        }else{
27
+            return Integer.toString(number);
28
+        }
29
+
30
+    }
31
+}

BIN
FizzBuzzTest.class Wyświetl plik


+ 14
- 0
FizzBuzzTest.ctxt Wyświetl plik

@@ -0,0 +1,14 @@
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=void\ setup()
6
+comment2.params=
7
+comment2.target=void\ test1()
8
+comment3.params=
9
+comment3.target=void\ test3()
10
+comment4.params=
11
+comment4.target=void\ test5()
12
+comment5.params=
13
+comment5.target=void\ test15()
14
+numComments=6

+ 41
- 0
FizzBuzzTest.java Wyświetl plik

@@ -0,0 +1,41 @@
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
+    private FizzBuzz fizzbuzz;
17
+    @Before
18
+    public void setup(){
19
+        fizzbuzz = new FizzBuzz();
20
+    }
21
+
22
+    @Test
23
+    public void test1(){
24
+        assertEquals(fizzbuzz.answer(1), "1");
25
+    }
26
+    
27
+    @Test
28
+    public void test3(){
29
+        assertEquals(fizzbuzz.answer(3), "fizz");
30
+    }
31
+    
32
+    @Test
33
+    public void test5(){
34
+        assertEquals(fizzbuzz.answer(5), "buzz");
35
+    }
36
+    
37
+    @Test
38
+    public void test15(){
39
+        assertEquals(fizzbuzz.answer(15), "fizzbuzz");
40
+    }
41
+}

+ 37
- 1
package.bluej Wyświetl plik

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