Quellcode durchsuchen

Added divide function and unit tests

Chaitali Patel vor 6 Jahren
Ursprung
Commit
0d4d6cab05
5 geänderte Dateien mit 35 neuen und 2 gelöschten Zeilen
  1. BIN
      Operations.class
  2. 15
    0
      Operations.ctxt
  3. 11
    2
      Operations.java
  4. BIN
      OperationsTest.class
  5. 9
    0
      OperationsTest.ctxt

BIN
Operations.class Datei anzeigen


+ 15
- 0
Operations.ctxt Datei anzeigen

@@ -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\ Division\ function\ \n\ \ @param\ x\ The\ first\ operand\n\ @param\ y\ The\ second\ operand\n\ @return\ x\ times\ y\n
15
+numComments=5

+ 11
- 2
Operations.java Datei anzeigen

@@ -19,7 +19,6 @@ public class Operations {
19 19
     public static int subtract(int x, int y) {
20 20
         return x - y;
21 21
     }
22
-    
23 22
 
24 23
     /**
25 24
      * The multiplication function
@@ -30,4 +29,14 @@ public class Operations {
30 29
     public static int multiply(int x, int y) {
31 30
         return x * y;
32 31
     }
33
-}
32
+
33
+    /** 
34
+     * The Division function 
35
+     *  @param x The first operand
36
+     * @param y The second operand
37
+     * @return x times y
38
+     */
39
+    public static int divide(int x, int y) {
40
+        return x / y;
41
+    }
42
+}

BIN
OperationsTest.class Datei anzeigen


+ 9
- 0
OperationsTest.ctxt Datei anzeigen

@@ -0,0 +1,9 @@
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
+numComments=4