Procházet zdrojové kódy

radians and degrees methods combined into one class

Yauheni Papko před 6 roky
rodič
revize
57267ed61a
4 změnil soubory, kde provedl 83 přidání a 211 odebrání
  1. 0
    76
      ScientificDegrees.java
  2. 0
    47
      ScientificDegreesTest.java
  3. 14
    5
      ScientificTest.java
  4. 69
    83
      package.bluej

+ 0
- 76
ScientificDegrees.java Zobrazit soubor

@@ -1,76 +0,0 @@
1
-
2
-/**
3
- * Write a description of class ScientificDegrees here.
4
- *
5
- * @author (your name)
6
- * @version (a version number or a date)
7
- */
8
-public class ScientificDegrees
9
-{
10
-    // instance variables - replace the example below with your own
11
-    private int x;
12
-
13
-    /**
14
-     * Constructor for objects of class ScientificDegrees
15
-     */
16
-    public ScientificDegrees()
17
-    {
18
-        // initialise instance variables
19
-        x = 0;
20
-    }
21
-
22
-    public static double sine(double angle)
23
-    {
24
-        
25
-
26
-        return Math.sin(angle) ;
27
-    }
28
-
29
-    public static double cosine(double angle)
30
-    {
31
-        
32
-
33
-        return Math.cos(angle) ;
34
-    }
35
-
36
-    public static double tangent(double angle)
37
-    {
38
-        
39
-
40
-        return Math.tan(angle) ;
41
-    }
42
-
43
-    public static double inverseSin(double angle)
44
-    {   
45
-
46
-        return Math.asin(angle) ;
47
-
48
-    }
49
-
50
-    public static double inverseCosine(double angle)
51
-    {
52
-        
53
-
54
-        return Math.acos(angle) ;
55
-    }
56
-
57
-    public static double inverseTangent(double angle)
58
-    {
59
-        
60
-
61
-        return Math.atan(angle) ;
62
-    }
63
-
64
-    /*public static BigInteger factorial(double number) {
65
-        double result = double.ValueOf(1);
66
-
67
-        for (double factor = 2; factor <= number.longValue(); factor++) {
68
-            result = result.multiply(double.valueOf(factor));
69
-        }
70
-
71
-        return result;
72
-    }*/
73
-}
74
-
75
-
76
-

+ 0
- 47
ScientificDegreesTest.java Zobrazit soubor

@@ -1,47 +0,0 @@
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
- * The test class ScientificDegreesTest.
9
- *
10
- * @author  (your name)
11
- * @version (a version number or a date)
12
- */
13
-public class ScientificDegreesTest
14
-{
15
-    private Scientific test;
16
-    public ScientificDegreesTest(){
17
-    }
18
-
19
-    /**
20
-     * Sets up the test fixture.
21
-     *
22
-     * Called before every test case method.
23
-     */
24
-    @Before
25
-    public void setUp()
26
-    {
27
-        Scientific test = new Scientific();
28
-    }
29
-
30
-    /**
31
-     * Tears down the test fixture.
32
-     *
33
-     * Called after every test case method.
34
-     */
35
-    @Test
36
-    public void testSine()
37
-    {
38
-        //expected
39
-        double expected = 1.0;
40
-        //actual
41
-        
42
-        double actual = test.sine(90.0,0);
43
-        //assertion
44
-        assertEquals(expected, actual, 0.1);
45
-    }
46
-    }
47
-

+ 14
- 5
ScientificTest.java Zobrazit soubor

@@ -34,14 +34,23 @@ public class ScientificTest
34 34
      * Called after every test case method.
35 35
      */
36 36
     @Test
37
-    public void testSine()
37
+    public void testSineDegrees()
38 38
     {
39 39
         //expected
40
-        double expected = 0.8;
40
+        double expected = 1.0;
41 41
         //actual
42
-        
43
-        double actual = Math.toRadians(90);
44
-        double actualSine = test.sine(actual);
42
+
43
+        double actualSine = test.sine(90.0,0);
44
+        //assertion
45
+        assertEquals(expected, actualSine, 0.1);
46
+    }
47
+    @Test
48
+    public void testSineRadians()
49
+    {
50
+        //expected
51
+        double expected = 0.5;
52
+        //actual
53
+        double actualSine = test.sine(0.52359877559,1);
45 54
         //assertion
46 55
         assertEquals(expected, actualSine, 0.1);
47 56
     }

+ 69
- 83
package.bluej Zobrazit soubor

@@ -8,7 +8,7 @@ dependency10.type=UsesDependency
8 8
 dependency11.from=Calculator
9 9
 dependency11.to=Scientific
10 10
 dependency11.type=UsesDependency
11
-dependency12.from=ScientificDegreesTest
11
+dependency12.from=ScientificTest
12 12
 dependency12.to=Scientific
13 13
 dependency12.type=UsesDependency
14 14
 dependency2.from=MainApplication
@@ -50,7 +50,7 @@ package.editor.y=70
50 50
 package.frame.height=759
51 51
 package.frame.width=1160
52 52
 package.numDependencies=12
53
-package.numTargets=17
53
+package.numTargets=15
54 54
 package.showExtends=true
55 55
 package.showUses=true
56 56
 project.charset=UTF-8
@@ -60,127 +60,113 @@ readme.width=47
60 60
 readme.x=10
61 61
 readme.y=10
62 62
 target1.height=50
63
-target1.name=ScientificDegrees
63
+target1.name=ScientificTest
64 64
 target1.showInterface=false
65
-target1.type=ClassTarget
66
-target1.width=140
67
-target1.x=780
68
-target1.y=270
65
+target1.type=UnitTestTargetJunit4
66
+target1.width=80
67
+target1.x=810
68
+target1.y=230
69
+target10.association=ConversionTest
69 70
 target10.height=50
70
-target10.name=CoreTest
71
+target10.name=DisplayMode
71 72
 target10.showInterface=false
72
-target10.type=UnitTestTargetJunit4
73
-target10.width=80
74
-target10.x=740
75
-target10.y=20
73
+target10.type=ClassTarget
74
+target10.width=110
75
+target10.x=180
76
+target10.y=390
76 77
 target11.height=50
77
-target11.name=MemoryTest
78
+target11.name=Calculator
78 79
 target11.showInterface=false
79
-target11.type=UnitTestTargetJunit4
80
-target11.width=80
81
-target11.x=140
82
-target11.y=230
83
-target12.association=ConversionTest
80
+target11.type=ClassTarget
81
+target11.width=90
82
+target11.x=510
83
+target11.y=180
84 84
 target12.height=50
85
-target12.name=DisplayMode
85
+target12.name=Console
86 86
 target12.showInterface=false
87 87
 target12.type=ClassTarget
88
-target12.width=110
89
-target12.x=110
90
-target12.y=380
88
+target12.width=80
89
+target12.x=450
90
+target12.y=470
91 91
 target13.height=50
92
-target13.name=Calculator
92
+target13.name=MainApplication
93 93
 target13.showInterface=false
94 94
 target13.type=ClassTarget
95
-target13.width=90
96
-target13.x=440
97
-target13.y=170
95
+target13.width=120
96
+target13.x=370
97
+target13.y=60
98
+target14.association=CoreTest
98 99
 target14.height=50
99
-target14.name=Console
100
+target14.name=Core
100 101
 target14.showInterface=false
101 102
 target14.type=ClassTarget
102 103
 target14.width=80
103
-target14.x=380
104
-target14.y=460
104
+target14.x=780
105
+target14.y=130
106
+target15.association=DisplayTest
105 107
 target15.height=50
106
-target15.name=MainApplication
108
+target15.name=Display
107 109
 target15.showInterface=false
108 110
 target15.type=ClassTarget
109
-target15.width=120
110
-target15.x=300
111
-target15.y=50
112
-target16.association=CoreTest
113
-target16.height=50
114
-target16.name=Core
115
-target16.showInterface=false
116
-target16.type=ClassTarget
117
-target16.width=80
118
-target16.x=710
119
-target16.y=50
120
-target17.association=DisplayTest
121
-target17.height=50
122
-target17.name=Display
123
-target17.showInterface=false
124
-target17.type=ClassTarget
125
-target17.width=80
126
-target17.x=30
127
-target17.y=120
111
+target15.width=80
112
+target15.x=100
113
+target15.y=130
114
+target2.association=MemoryTest
128 115
 target2.height=50
129
-target2.name=ScientificTest
116
+target2.name=Memory
130 117
 target2.showInterface=false
131
-target2.type=UnitTestTargetJunit4
118
+target2.type=ClassTarget
132 119
 target2.width=80
133
-target2.x=740
134
-target2.y=140
120
+target2.x=180
121
+target2.y=260
122
+target3.association=ScientificTest
135 123
 target3.height=50
136
-target3.name=ScientificDegreesTest
124
+target3.name=Scientific
137 125
 target3.showInterface=false
138
-target3.type=UnitTestTargetJunit4
139
-target3.width=160
140
-target3.x=800
141
-target3.y=240
142
-target4.association=MemoryTest
126
+target3.type=ClassTarget
127
+target3.width=80
128
+target3.x=780
129
+target3.y=260
143 130
 target4.height=50
144
-target4.name=Memory
131
+target4.name=CustomTest
145 132
 target4.showInterface=false
146
-target4.type=ClassTarget
133
+target4.type=UnitTestTargetJunit4
147 134
 target4.width=80
148
-target4.x=110
149
-target4.y=260
150
-target5.association=ScientificTest
135
+target4.x=810
136
+target4.y=360
137
+target5.association=CustomTest
151 138
 target5.height=50
152
-target5.name=Scientific
139
+target5.name=Custom
153 140
 target5.showInterface=false
154 141
 target5.type=ClassTarget
155 142
 target5.width=80
156
-target5.x=710
157
-target5.y=170
143
+target5.x=780
144
+target5.y=390
158 145
 target6.height=50
159
-target6.name=CustomTest
146
+target6.name=ConversionTest
160 147
 target6.showInterface=false
161 148
 target6.type=UnitTestTargetJunit4
162
-target6.width=80
163
-target6.x=740
164
-target6.y=350
165
-target7.association=CustomTest
149
+target6.width=110
150
+target6.x=210
151
+target6.y=360
166 152
 target7.height=50
167
-target7.name=Custom
153
+target7.name=DisplayTest
168 154
 target7.showInterface=false
169
-target7.type=ClassTarget
155
+target7.type=UnitTestTargetJunit4
170 156
 target7.width=80
171
-target7.x=710
172
-target7.y=380
157
+target7.x=130
158
+target7.y=100
173 159
 target8.height=50
174
-target8.name=ConversionTest
160
+target8.name=CoreTest
175 161
 target8.showInterface=false
176 162
 target8.type=UnitTestTargetJunit4
177
-target8.width=110
178
-target8.x=140
179
-target8.y=350
163
+target8.width=80
164
+target8.x=810
165
+target8.y=100
180 166
 target9.height=50
181
-target9.name=DisplayTest
167
+target9.name=MemoryTest
182 168
 target9.showInterface=false
183 169
 target9.type=UnitTestTargetJunit4
184 170
 target9.width=80
185
-target9.x=60
186
-target9.y=90
171
+target9.x=210
172
+target9.y=230