瀏覽代碼

fizzy buzzy fizz

rjsmall90 6 年之前
父節點
當前提交
d5b7bb9fbb
共有 6 個文件被更改,包括 152 次插入0 次删除
  1. 二進制
      FizzBuzz.class
  2. 14
    0
      FizzBuzz.ctxt
  3. 34
    0
      FizzBuzz.java
  4. 二進制
      FizzBuzzTest.class
  5. 16
    0
      FizzBuzzTest.ctxt
  6. 88
    0
      FizzBuzzTest.java

二進制
FizzBuzz.class 查看文件


+ 14
- 0
FizzBuzz.ctxt 查看文件

@@ -0,0 +1,14 @@
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
+comment2.params=input
7
+comment2.target=FizzBuzz(java.lang.Integer)
8
+comment3.params=
9
+comment3.target=java.lang.String\ fizz()
10
+comment4.params=
11
+comment4.target=java.lang.String\ buzz()
12
+comment5.params=
13
+comment5.target=java.lang.String\ fizzBuzz()
14
+numComments=6

+ 34
- 0
FizzBuzz.java 查看文件

@@ -0,0 +1,34 @@
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
+    Integer input; 
11
+    public FizzBuzz(){
12
+    
13
+    }
14
+    
15
+    public FizzBuzz(Integer input){
16
+    this.input = input; 
17
+    }
18
+  
19
+    public String fizz()
20
+    {
21
+       if(input%3==0) return "Fizz"; 
22
+        else return null; 
23
+    }
24
+    
25
+    public String buzz(){
26
+          if(input%5==0) return "Buzz"; 
27
+        else return null; 
28
+    }
29
+    
30
+    public String fizzBuzz(){
31
+          if(input%3 ==0 && input%5==0)  return "FizzBuzz"; 
32
+        else return null; 
33
+    }
34
+}

二進制
FizzBuzzTest.class 查看文件


+ 16
- 0
FizzBuzzTest.ctxt 查看文件

@@ -0,0 +1,16 @@
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\ testFizz1()
6
+comment2.params=
7
+comment2.target=void\ testFizz2()
8
+comment3.params=
9
+comment3.target=void\ testBuzz1()
10
+comment4.params=
11
+comment4.target=void\ testBuzz2()
12
+comment5.params=
13
+comment5.target=void\ testFizzBuzz1()
14
+comment6.params=
15
+comment6.target=void\ testFizzBuzz2()
16
+numComments=7

+ 88
- 0
FizzBuzzTest.java 查看文件

@@ -0,0 +1,88 @@
1
+import java.util.*; 
2
+import org.junit.After;
3
+import org.junit.Before;
4
+import org.junit.Test;
5
+import org.junit.Assert;
6
+
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
+    @Test
17
+    public void testFizz1(){
18
+        Integer input = 3; 
19
+        
20
+        FizzBuzz fizzBuzz = new FizzBuzz(input);
21
+        String expected = "Fizz";
22
+        String actual = fizzBuzz.fizz(); 
23
+      
24
+        Assert.assertEquals(expected, actual); 
25
+    }
26
+    
27
+    @Test
28
+    public void testFizz2(){
29
+        Integer input = 9; 
30
+        
31
+        FizzBuzz fizzBuzz = new FizzBuzz(input);
32
+        String expected = "Fizz";
33
+        String actual = fizzBuzz.fizz(); 
34
+      
35
+        Assert.assertEquals(expected, actual); 
36
+    }
37
+    
38
+    @Test 
39
+    public void testBuzz1(){
40
+        Integer input = 5; 
41
+        
42
+        FizzBuzz fizzBuzz = new FizzBuzz(input);
43
+        String expected = "Buzz";
44
+        String actual = fizzBuzz.buzz(); 
45
+      
46
+        
47
+        Assert.assertEquals(expected, actual); 
48
+    }
49
+        
50
+    @Test 
51
+    public void testBuzz2(){
52
+        Integer input = 10; 
53
+        
54
+        FizzBuzz fizzBuzz = new FizzBuzz(input);
55
+        String expected = "Buzz";
56
+        String actual = fizzBuzz.buzz(); 
57
+      
58
+        
59
+        Assert.assertEquals(expected, actual); 
60
+    }
61
+    
62
+    @Test
63
+    public void testFizzBuzz1(){
64
+        Integer input = 15;
65
+        
66
+        FizzBuzz fizzBuzz = new FizzBuzz(input);
67
+        String expected = "FizzBuzz";
68
+        String actual = fizzBuzz.fizzBuzz(); 
69
+      
70
+        
71
+        Assert.assertEquals(expected, actual); 
72
+    
73
+    }
74
+    
75
+    @Test
76
+    public void testFizzBuzz2(){
77
+        Integer input = 30;
78
+        
79
+        FizzBuzz fizzBuzz = new FizzBuzz(input);
80
+        String expected = "FizzBuzz";
81
+        String actual = fizzBuzz.fizzBuzz(); 
82
+      
83
+        
84
+        Assert.assertEquals(expected, actual); 
85
+    
86
+    }
87
+
88
+}