浏览代码

Added divide function and unit tests

Chad 6 年前
父节点
当前提交
c7ca3927e1
共有 6 个文件被更改,包括 41 次插入0 次删除
  1. 二进制
      Operations.class
  2. 15
    0
      Operations.ctxt
  3. 10
    0
      Operations.java
  4. 二进制
      OperationsTest.class
  5. 11
    0
      OperationsTest.ctxt
  6. 5
    0
      OperationsTest.java

二进制
Operations.class 查看文件


+ 15
- 0
Operations.ctxt 查看文件

@@ -0,0 +1,15 @@
1
+#BlueJ class context
2
+comment0.target=Operations
3
+comment1.params=x\ y
4
+comment1.target=int\ add(int,\ int)
5
+comment1.text=\n\ The\ addition\ function.\n\ @param\ x\ The\ first\ operand\n\ @param\ y\ The\ second\ operand\n\ @return\ the\ sum\ of\ x\ and\ y\n
6
+comment2.params=x\ y
7
+comment2.target=int\ subtract(int,\ int)
8
+comment2.text=\n\ The\ subtraction\ function\n\ @param\ x\ The\ first\ operand\n\ @param\ y\ The\ second\ operand\n\ @return\ y\ taken\ from\ x\n
9
+comment3.params=x\ y
10
+comment3.target=int\ multiply(int,\ int)
11
+comment3.text=\n\ The\ multiplication\ function\n\ @param\ x\ The\ first\ operand\n\ @param\ y\ The\ second\ operand\n\ @return\ x\ times\ y\n
12
+comment4.params=x\ y
13
+comment4.target=int\ divide(int,\ int)
14
+comment4.text=\n\ The\ divide\ function.\n\ @param\ x\ The\ first\ operand\n\ @param\ y\ The\ second\ operand\n\ @return\ the\ division\ of\ x\ and\ y\n
15
+numComments=5

+ 10
- 0
Operations.java 查看文件

@@ -30,4 +30,14 @@ public class Operations {
30 30
     public static int multiply(int x, int y) {
31 31
         return x * y;
32 32
     }
33
+    
34
+    /**
35
+     * The divide function.
36
+     * @param x The first operand
37
+     * @param y The second operand
38
+     * @return the division of x and y
39
+     */
40
+    public static int divide(int x, int y) {
41
+        return x / y;
42
+    }
33 43
 }

二进制
OperationsTest.class 查看文件


+ 11
- 0
OperationsTest.ctxt 查看文件

@@ -0,0 +1,11 @@
1
+#BlueJ class context
2
+comment0.target=OperationsTest
3
+comment1.params=
4
+comment1.target=void\ testAdd()
5
+comment2.params=
6
+comment2.target=void\ testSubtract()
7
+comment3.params=
8
+comment3.target=void\ testMultiply()
9
+comment4.params=
10
+comment4.target=void\ testDivide()
11
+numComments=5

+ 5
- 0
OperationsTest.java 查看文件

@@ -16,4 +16,9 @@ public class OperationsTest {
16 16
     public void testMultiply() throws Exception {
17 17
         Assert.assertEquals(4, Operations.multiply(2, 2));
18 18
     }
19
+    
20
+    @Test
21
+    public void testDivide() throws Exception {
22
+        Assert.assertEquals(1, Operations.divide(2, 2));
23
+    }
19 24
 }