Khalil Saboor il y a 6 ans
Parent
révision
30166910ba
3 fichiers modifiés avec 202 ajouts et 2 suppressions
  1. 65
    0
      TrigFunctions.java
  2. 79
    0
      TrigFunctionsTest.java
  3. 58
    2
      package.bluej

+ 65
- 0
TrigFunctions.java Voir le fichier

@@ -0,0 +1,65 @@
1
+
2
+/**
3
+ * Write a description of class TrigFunctions here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+import java.lang.Math;
9
+import java.util.Scanner;
10
+
11
+public class TrigFunctions
12
+{
13
+    // instance variables - replace the example below with your own
14
+   
15
+
16
+    /**
17
+     * Constructor for objects of class TrigFunctions
18
+     */
19
+    public TrigFunctions()
20
+    {
21
+        ;// initialise instance variables
22
+        ;
23
+    }
24
+
25
+    public double sin(int number){
26
+     double value = Math.sin(number);
27
+     return value;
28
+    }
29
+    
30
+    
31
+    public double cos(int number){
32
+        double value = Math.cos(number);
33
+        return value;
34
+    }
35
+    
36
+    public double tan(int number){
37
+        double value = Math.tan(number);
38
+        return value;   
39
+    }
40
+    
41
+    public double invsin(int number){
42
+        double value = Math.asin(number);
43
+        return value;
44
+    }
45
+    
46
+    public double invcos(int number){
47
+        double value = Math.acos(number);
48
+        return value;
49
+    }
50
+    
51
+    public double invtan(int number){
52
+        double value = Math.atan(number);
53
+        return value;   
54
+    }
55
+    
56
+    public double deg(int number){
57
+        double value = Math.toDegrees(number);
58
+        return value;
59
+    }
60
+    
61
+    public double rad(int number){
62
+        double value = Math.toRadians(number);
63
+        return value;   
64
+    }
65
+} //end Class TrigFunctions

+ 79
- 0
TrigFunctionsTest.java Voir le fichier

@@ -0,0 +1,79 @@
1
+
2
+import static org.junit.Assert.*;
3
+import org.junit.After;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+/**
8
+ * The test class TrigFunctionsTest.
9
+ *
10
+ * @author  (your name)
11
+ * @version (a version number or a date)
12
+ */
13
+public class TrigFunctionsTest
14
+{
15
+   @Test
16
+   public void sinTest(){
17
+       TrigFunctions trigFunctions = new TrigFunctions();
18
+       double expected = -0.95;
19
+       double actual = trigFunctions.sin(5);
20
+       assertEquals(expected,actual,0.01);
21
+       
22
+    }
23
+    
24
+   @Test
25
+   public void cosTest(){
26
+       TrigFunctions trigFunctions = new TrigFunctions();
27
+       double expected = 0.28;
28
+       double actual = trigFunctions.cos(5);
29
+       assertEquals(expected,actual, 0.01);
30
+    }
31
+    
32
+    @Test
33
+    public void tanTest(){
34
+      TrigFunctions trigFunctions = new TrigFunctions();
35
+      double expected = -3.38;
36
+      double actual = trigFunctions.tan(5);
37
+      assertEquals(expected,actual, 0.01);
38
+    }
39
+    
40
+   @Test
41
+   public void invsinTest(){
42
+     TrigFunctions trigFunctions = new TrigFunctions();
43
+     double expected = 1.57;
44
+     double actual = trigFunctions.invsin(1);
45
+     assertEquals(expected,actual, 0.01);
46
+    }
47
+    
48
+    @Test
49
+    public void invcosTest(){
50
+     TrigFunctions trigFunctions = new TrigFunctions();
51
+     double expected = 0;
52
+     double actual = trigFunctions.invcos(1);
53
+     assertEquals(expected,actual, 0.01);
54
+    }
55
+    
56
+    @Test
57
+    public void invtanTest(){
58
+     TrigFunctions trigFunctions = new TrigFunctions();
59
+     double expected = 0.79;
60
+     double actual = trigFunctions.invtan(1);
61
+     assertEquals(expected,actual, 0.01);
62
+    }
63
+    
64
+    @Test
65
+    public void degTest(){
66
+    TrigFunctions trigFunctions = new TrigFunctions();
67
+    double expected = 286.48;
68
+    double actual = trigFunctions.deg(5);
69
+    assertEquals(expected,actual, 0.01);
70
+    }
71
+    
72
+    @Test
73
+    public void radTest(){
74
+     TrigFunctions trigFunctions = new TrigFunctions();
75
+     double expected = 0.87;
76
+     double actual = trigFunctions.rad(50);
77
+     assertEquals(expected,actual, 0.01);
78
+    }
79
+}

+ 58
- 2
package.bluej Voir le fichier

@@ -1,7 +1,8 @@
1 1
 #BlueJ package file
2
-dependency1.from=MainApplication
3
-dependency1.to=Console
2
+dependency1.from=BasicMathTest
3
+dependency1.to=BasicMath
4 4
 dependency1.type=UsesDependency
5
+<<<<<<< HEAD
5 6
 dependency2.from=BasicMathTest
6 7
 dependency2.to=BasicMath
7 8
 dependency2.type=UsesDependency
@@ -9,6 +10,18 @@ editor.fx.0.height=0
9 10
 editor.fx.0.width=0
10 11
 editor.fx.0.x=0
11 12
 editor.fx.0.y=0
13
+=======
14
+dependency2.from=MainApplication
15
+dependency2.to=Console
16
+dependency2.type=UsesDependency
17
+dependency3.from=TrigFunctionsTest
18
+dependency3.to=TrigFunctions
19
+dependency3.type=UsesDependency
20
+editor.fx.0.height=722
21
+editor.fx.0.width=800
22
+editor.fx.0.x=155
23
+editor.fx.0.y=23
24
+>>>>>>> 7d1ea52de1c614ccaeb20bec6a6c3ced4ce15339
12 25
 objectbench.height=202
13 26
 objectbench.width=352
14 27
 package.divider.horizontal=0.5993322203672788
@@ -19,8 +32,13 @@ package.editor.x=35
19 32
 package.editor.y=23
20 33
 package.frame.height=722
21 34
 package.frame.width=619
35
+<<<<<<< HEAD
22 36
 package.numDependencies=2
23 37
 package.numTargets=5
38
+=======
39
+package.numDependencies=3
40
+package.numTargets=7
41
+>>>>>>> 7d1ea52de1c614ccaeb20bec6a6c3ced4ce15339
24 42
 package.showExtends=true
25 43
 package.showUses=true
26 44
 project.charset=UTF-8
@@ -35,8 +53,13 @@ target1.name=BasicMath
35 53
 target1.showInterface=false
36 54
 target1.type=ClassTarget
37 55
 target1.width=90
56
+<<<<<<< HEAD
38 57
 target1.x=320
39 58
 target1.y=130
59
+=======
60
+target1.x=220
61
+target1.y=160
62
+>>>>>>> 7d1ea52de1c614ccaeb20bec6a6c3ced4ce15339
40 63
 target2.height=50
41 64
 target2.name=MainApplicationTest
42 65
 target2.showInterface=false
@@ -51,6 +74,7 @@ target3.type=ClassTarget
51 74
 target3.width=80
52 75
 target3.x=80
53 76
 target3.y=200
77
+<<<<<<< HEAD
54 78
 target4.height=50
55 79
 target4.name=BasicMathTest
56 80
 target4.showInterface=false
@@ -66,3 +90,35 @@ target5.type=ClassTarget
66 90
 target5.width=120
67 91
 target5.x=70
68 92
 target5.y=70
93
+=======
94
+target4.association=TrigFunctionsTest
95
+target4.height=50
96
+target4.name=TrigFunctions
97
+target4.showInterface=false
98
+target4.type=ClassTarget
99
+target4.width=110
100
+target4.x=40
101
+target4.y=300
102
+target5.height=50
103
+target5.name=BasicMathTest
104
+target5.showInterface=false
105
+target5.type=UnitTestTargetJunit4
106
+target5.width=120
107
+target5.x=330
108
+target5.y=170
109
+target6.height=50
110
+target6.name=TrigFunctionsTest
111
+target6.showInterface=false
112
+target6.type=UnitTestTargetJunit4
113
+target6.width=110
114
+target6.x=70
115
+target6.y=270
116
+target7.association=MainApplicationTest
117
+target7.height=50
118
+target7.name=MainApplication
119
+target7.showInterface=false
120
+target7.type=ClassTarget
121
+target7.width=120
122
+target7.x=70
123
+target7.y=70
124
+>>>>>>> 7d1ea52de1c614ccaeb20bec6a6c3ced4ce15339