Browse Source

Added divide function and unit tests

Michelle DiMarino 6 years ago
parent
commit
ac15c59a7c
2 changed files with 10 additions and 2 deletions
  1. 6
    2
      Operations.java
  2. 4
    0
      OperationsTest.java

+ 6
- 2
Operations.java View File

@@ -19,8 +19,12 @@ public class Operations {
19 19
     public static int subtract(int x, int y) {
20 20
         return x - y;
21 21
     }
22
-    
23
-
22
+/**
23
+*The divide function
24
+*/    
25
+public static int divide(int x, int y){
26
+return x/y;
27
+}
24 28
     /**
25 29
      * The multiplication function
26 30
      * @param x The first operand

+ 4
- 0
OperationsTest.java View File

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