Khalil Saboor hace 6 años
padre
commit
3bfd226a55
Se han modificado 4 ficheros con 146 adiciones y 18 borrados
  1. 34
    0
      BasicMath.java
  2. 44
    0
      BasicMathTest.java
  3. 42
    0
      MainApplicationTest.java
  4. 26
    18
      package.bluej

+ 34
- 0
BasicMath.java Ver fichero

@@ -0,0 +1,34 @@
1
+
2
+/**
3
+ * Write a description of class BasicMath here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+import java.util.*;
9
+import java.lang.*;
10
+import java.io.*;
11
+public class BasicMath
12
+{
13
+   public static double add(double a,double b) {  
14
+            return a + b;
15
+        }
16
+    public static double Subtract(double a,double b){
17
+            return a - b;
18
+        }
19
+    public static double multiply(double a,double b){
20
+            return a * b;
21
+        }
22
+    public static double divide(double a,double b){
23
+            return a / b;
24
+        }
25
+    public static double power(double a, double b){
26
+            return Math.pow(a,b);
27
+        } 
28
+    public static double squareRoot(double a){
29
+            return Math.sqrt(a);
30
+        }   
31
+    public static double inverse(double a){
32
+        return 1/a;
33
+    }
34
+}

+ 44
- 0
BasicMathTest.java Ver fichero

@@ -0,0 +1,44 @@
1
+
2
+import static org.junit.Assert.*;
3
+import org.junit.Test;
4
+import org.junit.Assert;
5
+
6
+/**
7
+ * The test class BasicMathTest.
8
+ *
9
+ * @author  (your name)
10
+ * @version (a version number or a date)
11
+ */
12
+public class BasicMathTest
13
+{
14
+    @Test
15
+    public void CalculatorTest()
16
+    {                      //expected          plug      delta
17
+        Assert.assertEquals(100.1, BasicMath.add(99.1,1.0), 2.00);
18
+    }
19
+     @Test
20
+    public void testSubtract(){
21
+        Assert.assertEquals(0.0, BasicMath.Subtract(1.0, 1.0), 0.00);
22
+    }
23
+      @Test
24
+    public void testmultiply(){
25
+        Assert.assertEquals(4.0, BasicMath.multiply(2.0, 2.0), 2.00);
26
+    }
27
+      @Test
28
+    public void testdivide(){
29
+        Assert.assertEquals(7.0, BasicMath.divide(14.0, 2.0), 7.00);
30
+    }
31
+      @Test
32
+    public void testpower(){
33
+        Assert.assertEquals(1.0, BasicMath.power(1.0, 1.0), 0.00);
34
+    }
35
+      @Test
36
+    public void testsquareRoot(){
37
+        Assert.assertEquals(3.0, BasicMath.squareRoot(9.00) , 9.00);
38
+    }
39
+      @Test
40
+    public void testinverse(){
41
+        Assert.assertEquals(0.5, BasicMath.inverse(2.00) , 00.5);
42
+    }
43
+}
44
+

+ 42
- 0
MainApplicationTest.java Ver fichero

@@ -0,0 +1,42 @@
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 MainApplicationTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class MainApplicationTest
15
+{
16
+    /**
17
+     * Default constructor for test class MainApplicationTest
18
+     */
19
+    public MainApplicationTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+}

+ 26
- 18
package.bluej Ver fichero

@@ -4,20 +4,20 @@ dependency1.to=Console
4 4
 dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6 6
 editor.fx.0.width=800
7
-editor.fx.0.x=640
7
+editor.fx.0.x=480
8 8
 editor.fx.0.y=23
9
-objectbench.height=214
10
-objectbench.width=595
11
-package.divider.horizontal=0.6
12
-package.divider.vertical=0.6847360912981455
13
-package.editor.height=473
9
+objectbench.height=202
10
+objectbench.width=352
11
+package.divider.horizontal=0.5993322203672788
12
+package.divider.vertical=0.6852409638554217
13
+package.editor.height=448
14 14
 package.editor.width=493
15 15
 package.editor.x=35
16
-package.editor.y=60
17
-package.frame.height=759
16
+package.editor.y=23
17
+package.frame.height=722
18 18
 package.frame.width=619
19 19
 package.numDependencies=1
20
-package.numTargets=2
20
+package.numTargets=3
21 21
 package.showExtends=true
22 22
 package.showUses=true
23 23
 project.charset=UTF-8
@@ -27,16 +27,24 @@ readme.width=47
27 27
 readme.x=10
28 28
 readme.y=10
29 29
 target1.height=50
30
-target1.name=Console
30
+target1.name=MainApplicationTest
31 31
 target1.showInterface=false
32
-target1.type=ClassTarget
33
-target1.width=80
34
-target1.x=80
35
-target1.y=200
32
+target1.type=UnitTestTargetJunit4
33
+target1.width=120
34
+target1.x=100
35
+target1.y=40
36 36
 target2.height=50
37
-target2.name=MainApplication
37
+target2.name=Console
38 38
 target2.showInterface=false
39 39
 target2.type=ClassTarget
40
-target2.width=120
41
-target2.x=70
42
-target2.y=70
40
+target2.width=80
41
+target2.x=80
42
+target2.y=200
43
+target3.association=MainApplicationTest
44
+target3.height=50
45
+target3.name=MainApplication
46
+target3.showInterface=false
47
+target3.type=ClassTarget
48
+target3.width=120
49
+target3.x=70
50
+target3.y=70