Bladeren bron

added deg and rad tests, added fortune method, deleted old comments

Margaret Pierse 6 jaren geleden
bovenliggende
commit
8b5acab026
4 gewijzigde bestanden met toevoegingen van 34 en 55 verwijderingen
  1. 3
    1
      Calculator.java
  2. 8
    48
      MathMethods.java
  3. 17
    0
      MathMethodsTest.java
  4. 6
    6
      package.bluej

+ 3
- 1
Calculator.java Bestand weergeven

@@ -1,4 +1,3 @@
1
-
2 1
 import java.util.*;
3 2
 class Calculator{
4 3
     public static void main(String args[]){
@@ -119,6 +118,9 @@ class Calculator{
119 118
                     memory = result;
120 119
                     calc.printAns(String.valueOf(result));
121 120
                     break;
121
+                    
122
+                    case "fortune cookie":
123
+                    
122 124
                 }
123 125
             }
124 126
 

+ 8
- 48
MathMethods.java Bestand weergeven

@@ -70,10 +70,13 @@ public class MathMethods
70 70
     }
71 71
 
72 72
     public static String fortuneCookie() {
73
-     String[] wiseWords = new String[] {"You're a hard worker and you will do great on all the labs!", 
74
-         "Look how much java you learned this week! That's awesome!", "Keep up the good Work" ,
75
-        "Don't forget to talk to our visitors, they give us jobs!"};  
76
-        return "";
73
+     Random rand = new Random();
74
+        String[] wiseWords = new String[] {"You're a hard worker and you will do great on all the labs!", 
75
+         "Look how much java you learned this week! That's awesome!", "Keep up the good work!" ,
76
+        "You're cushing it!", "You're a coding rockstar!", 
77
+        "Keep coding!"};  
78
+        int arrIndex = rand.nextInt(6)+1;
79
+        return wiseWords[arrIndex];
77 80
     }
78 81
     
79 82
     public static void printAns(String printAnswer){
@@ -87,47 +90,4 @@ public class MathMethods
87 90
     
88 91
     
89 92
     
90
-    
91
-// public static double squareRoot(double n1) {
92
-// double result = Math.sqrt(x);
93
-// return result;
94
-// }
95
-
96
-// public static double invert(double n1) {
97
-// double result = x*-1;
98
-// return result;
99
-// }
100
-
101
-// public static double sin(double n1){
102
-// double result = Math.sin(x);
103
-// return result;
104
-// }
105
-
106
-// public static double iSin(double n1){
107
-// double result = Math.asin(x);
108
-// return result;
109
-// }
110
-
111
-// public static double degToRad(double n1) {
112
-// double result = Math.toRadians(x);
113
-// return result;
114
-// }
115
-
116
-// public static double radToDeg(double n1) {
117
-// double result = Math.toDegrees(x);
118
-// return result;
119
-// }
120
-
121
-// public static Double exponent(double n1, double n2){
122
-// return (Math.pow(n1, n2));
123
-// }
124
-
125
-// public static Double cosine(double n1){
126
-// return (Math.cos(n1));
127
-// }
128
-
129
-// public static Double invCosine(double n1){
130
-// return (Math.acos(n1));
131
-// }
132
-
133
-
93
+ 

+ 17
- 0
MathMethodsTest.java Bestand weergeven

@@ -63,8 +63,25 @@ public class MathMethodsTest
63 63
     {
64 64
         assertEquals(-0.26237485370392877, MathMethods.sin(50), 0.1);
65 65
     }
66
+
67
+    @Test
68
+    public void testDegToRad()
69
+    {
70
+        assertEquals(0.3490658503988659, MathMethods.degToRad(20), 0.1);
71
+    }
72
+
73
+    @Test
74
+    public void testRadToDeg()
75
+    {
76
+        assertEquals(57.2957791308232, MathMethods.radToDeg(1), 0.1);
77
+    }
78
+
79
+    
66 80
 }
67 81
 
68 82
 
69 83
 
70 84
 
85
+
86
+
87
+

+ 6
- 6
package.bluej Bestand weergeven

@@ -5,18 +5,18 @@ dependency1.type=UsesDependency
5 5
 dependency2.from=MathMethodsTest
6 6
 dependency2.to=MathMethods
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=0
9
-editor.fx.0.width=0
10
-editor.fx.0.x=0
11
-editor.fx.0.y=0
8
+editor.fx.0.height=722
9
+editor.fx.0.width=800
10
+editor.fx.0.x=615
11
+editor.fx.0.y=114
12 12
 objectbench.height=80
13 13
 objectbench.width=480
14 14
 package.divider.horizontal=0.5997536945812808
15 15
 package.divider.vertical=0.8838451268357811
16 16
 package.editor.height=655
17 17
 package.editor.width=706
18
-package.editor.x=10
19
-package.editor.y=23
18
+package.editor.x=100
19
+package.editor.y=26
20 20
 package.frame.height=807
21 21
 package.frame.width=832
22 22
 package.numDependencies=2