Jennifer Tinkler 6 лет назад
Родитель
Сommit
766f19908f
3 измененных файлов: 73 добавлений и 30 удалений
  1. 33
    7
      MathUtilities.java
  2. 19
    1
      StringUtilities.java
  3. 21
    22
      package.bluej

+ 33
- 7
MathUtilities.java Просмотреть файл

1
+
2
+
3
+
4
+
5
+
6
+
7
+
1
 public class MathUtilities{
8
 public class MathUtilities{
2
   /**
9
   /**
3
    * Add two number together
10
    * Add two number together
5
    * @param num2 second number
12
    * @param num2 second number
6
    * @return the sum of the two numbers
13
    * @return the sum of the two numbers
7
    */
14
    */
15
+  
16
+  
8
   public int add(int num1, int num2){
17
   public int add(int num1, int num2){
9
-      return -1;
18
+      
19
+  return (num1 + num2);
20
+
21
+   
10
   }
22
   }
11
 
23
 
12
   /**
24
   /**
15
    * @param num2 second number
27
    * @param num2 second number
16
    * @return the sum of the two numbers
28
    * @return the sum of the two numbers
17
    */
29
    */
18
-  public double add(double num1, double num2){
19
-      return -1;
30
+  public double add(double num1, double num2){ 
31
+      
32
+      return (num1 + num2); 
33
+     
20
   }
34
   }
21
 
35
 
22
   /**
36
   /**
25
    * @return the half of the number in double
39
    * @return the half of the number in double
26
    */
40
    */
27
   public double half(int number) {
41
   public double half(int number) {
28
-      return -1;
42
+      //if either number is a double the int will be converted into a double
43
+     d = (number/2); 
44
+      
45
+      return d;
29
   }
46
   }
30
 
47
 
31
   /**
48
   /**
33
    * @param number the number given
50
    * @param number the number given
34
    * @return true if the number is odd, false if it is even
51
    * @return true if the number is odd, false if it is even
35
    */
52
    */
53
+
54
+  
36
   public boolean isOdd(int number){
55
   public boolean isOdd(int number){
37
-      return false;
56
+      
57
+          
58
+          
59
+      if ( number % 2 == 0); return false;
60
+      
61
+     else return true;
62
+    
38
   }
63
   }
39
-
64
+ 
40
 
65
 
41
   /**
66
   /**
42
    * Multiply the number by itself
67
    * Multiply the number by itself
44
    * @return the result of the number multiply by itself
69
    * @return the result of the number multiply by itself
45
    */
70
    */
46
   public int square(int number) {
71
   public int square(int number) {
47
-      return -1;
72
+      
73
+      return (number * number);
48
   }
74
   }
49
 
75
 
50
 }
76
 }

+ 19
- 1
StringUtilities.java Просмотреть файл

1
+import java.util.Scanner;
2
+
1
 public class StringUtilities {
3
 public class StringUtilities {
2
    public Character getMiddleCharacter(String word){
4
    public Character getMiddleCharacter(String word){
3
-       return null;
5
+       //get the middle of the string
6
+       
7
+        if (str.length() <= 2) {
8
+            
9
+         return str;
10
+      }
11
+      int beginIndex = (str.length() - 1) / 2;
12
+      
13
+      int endIndex = beginIndex + 2 - (str.length() % 2);
14
+      
15
+      return str.substring(beginIndex, endIndex);
4
    }
16
    }
17
+       
18
+ 
19
+      
20
+ }
5
    
21
    
6
    public String removeCharacter(String value, char charToRemove){
22
    public String removeCharacter(String value, char charToRemove){
23
+       
24
+       
7
      return null;  
25
      return null;  
8
    }
26
    }
9
    
27
    

+ 21
- 22
package.bluej Просмотреть файл

2
 dependency1.from=StringUtilitiesTest
2
 dependency1.from=StringUtilitiesTest
3
 dependency1.to=StringUtilities
3
 dependency1.to=StringUtilities
4
 dependency1.type=UsesDependency
4
 dependency1.type=UsesDependency
5
-dependency2.from=BonusTest
6
-dependency2.to=Bonus
5
+dependency2.from=LoopFunTest
6
+dependency2.to=LoopFun
7
 dependency2.type=UsesDependency
7
 dependency2.type=UsesDependency
8
 dependency3.from=MathUtilitiesTest
8
 dependency3.from=MathUtilitiesTest
9
 dependency3.to=MathUtilities
9
 dependency3.to=MathUtilities
10
 dependency3.type=UsesDependency
10
 dependency3.type=UsesDependency
11
 editor.fx.0.height=722
11
 editor.fx.0.height=722
12
 editor.fx.0.width=876
12
 editor.fx.0.width=876
13
-editor.fx.0.x=158
14
-editor.fx.0.y=216
15
-objectbench.height=164
13
+editor.fx.0.x=-293
14
+editor.fx.0.y=-996
15
+objectbench.height=163
16
 objectbench.width=669
16
 objectbench.width=669
17
 package.divider.horizontal=0.6
17
 package.divider.horizontal=0.6
18
-package.divider.vertical=0.7628294036061026
19
-package.editor.height=543
18
+package.divider.vertical=0.7635605006954103
19
+package.editor.height=542
20
 package.editor.width=567
20
 package.editor.width=567
21
-package.editor.x=557
22
-package.editor.y=43
23
-package.frame.height=779
21
+package.editor.x=593
22
+package.editor.y=-1057
23
+package.frame.height=777
24
 package.frame.width=693
24
 package.frame.width=693
25
 package.numDependencies=3
25
 package.numDependencies=3
26
 package.numTargets=6
26
 package.numTargets=6
37
 target1.showInterface=false
37
 target1.showInterface=false
38
 target1.type=UnitTestTargetJunit4
38
 target1.type=UnitTestTargetJunit4
39
 target1.width=110
39
 target1.width=110
40
-target1.x=110
41
-target1.y=150
40
+target1.x=100
41
+target1.y=190
42
 target2.height=50
42
 target2.height=50
43
-target2.name=BonusTest
43
+target2.name=LoopFunTest
44
 target2.showInterface=false
44
 target2.showInterface=false
45
 target2.type=UnitTestTargetJunit4
45
 target2.type=UnitTestTargetJunit4
46
-target2.width=80
47
-target2.x=120
48
-target2.y=270
49
-target3.association=BonusTest
46
+target2.width=110
47
+target2.x=10
48
+target2.y=330
50
 target3.height=50
49
 target3.height=50
51
-target3.name=Bonus
50
+target3.name=LoopFun
52
 target3.showInterface=false
51
 target3.showInterface=false
53
 target3.type=ClassTarget
52
 target3.type=ClassTarget
54
 target3.width=80
53
 target3.width=80
55
-target3.x=90
56
-target3.y=300
54
+target3.x=40
55
+target3.y=390
57
 target4.association=MathUtilitiesTest
56
 target4.association=MathUtilitiesTest
58
 target4.height=50
57
 target4.height=50
59
 target4.name=MathUtilities
58
 target4.name=MathUtilities
68
 target5.showInterface=false
67
 target5.showInterface=false
69
 target5.type=ClassTarget
68
 target5.type=ClassTarget
70
 target5.width=110
69
 target5.width=110
71
-target5.x=80
72
-target5.y=180
70
+target5.x=70
71
+target5.y=220
73
 target6.height=50
72
 target6.height=50
74
 target6.name=MathUtilitiesTest
73
 target6.name=MathUtilitiesTest
75
 target6.showInterface=false
74
 target6.showInterface=false