De'Jon Johnson před 6 roky
rodič
revize
5e8eb22c2f
4 změnil soubory, kde provedl 49 přidání a 35 odebrání
  1. 1
    1
      LoopFun.java
  2. 16
    5
      MathUtilities.java
  3. 18
    11
      StringUtilities.java
  4. 14
    18
      package.bluej

+ 1
- 1
LoopFun.java Zobrazit soubor

@@ -8,7 +8,7 @@ public class LoopFun
8 8
        * @return the factorial of the number
9 9
        */
10 10
       public int factorial(int number){
11
-          return -1;
11
+         return -1;
12 12
       }
13 13
 
14 14
       /**

+ 16
- 5
MathUtilities.java Zobrazit soubor

@@ -6,7 +6,10 @@ public class MathUtilities{
6 6
    * @return the sum of the two numbers
7 7
    */
8 8
   public int add(int num1, int num2){
9
-      return -1;
9
+      int number = (num1 + num2);
10
+      return number;
11
+      
12
+      
10 13
   }
11 14
 
12 15
   /**
@@ -16,7 +19,8 @@ public class MathUtilities{
16 19
    * @return the sum of the two numbers
17 20
    */
18 21
   public double add(double num1, double num2){
19
-      return -1;
22
+      double stuff = (num1 + num2);
23
+      return stuff;
20 24
   }
21 25
 
22 26
   /**
@@ -25,7 +29,9 @@ public class MathUtilities{
25 29
    * @return the half of the number in double
26 30
    */
27 31
   public double half(int number) {
28
-      return -1;
32
+     double answer = (double)(number/2);
33
+     return answer;
34
+      
29 35
   }
30 36
 
31 37
   /**
@@ -34,7 +40,11 @@ public class MathUtilities{
34 40
    * @return true if the number is odd, false if it is even
35 41
    */
36 42
   public boolean isOdd(int number){
37
-      return false;
43
+        if(number % 2 != 0){
44
+          return true;
45
+        } else{
46
+        return false; 
47
+        }
38 48
   }
39 49
 
40 50
 
@@ -44,7 +54,8 @@ public class MathUtilities{
44 54
    * @return the result of the number multiply by itself
45 55
    */
46 56
   public int square(int number) {
47
-      return -1;
57
+      return (number*number);
58
+      
48 59
   }
49 60
 
50 61
 }

+ 18
- 11
StringUtilities.java Zobrazit soubor

@@ -1,13 +1,20 @@
1 1
 public class StringUtilities {
2
-   public Character getMiddleCharacter(String word){
3
-       return null;
4
-   }
5
-   
6
-   public String removeCharacter(String value, char charToRemove){
7
-     return null;  
8
-   }
9
-   
10
-   public String getLastWord(String value) {
11
-       return null;
12
-   }
2
+    public Character getMiddleCharacter(String word){
3
+           int newWord = word.length();
4
+        if (newWord % 2 == 0) {
5
+            return word.charAt((newWord/2) -1);
6
+        }else{
7
+        return word.charAt((newWord-1)/2);
8
+        }
9
+    }
10
+
11
+    public String removeCharacter(String value, char charToRemove){
12
+        return null;  
13
+    }
14
+
15
+    public String getLastWord(String value) {
16
+        String newWord = value.substring(value.lastIndexOf(' '),value.length());
17
+        return newWord;
18
+        
19
+    }
13 20
 }

+ 14
- 18
package.bluej Zobrazit soubor

@@ -1,17 +1,14 @@
1 1
 #BlueJ package file
2
-dependency1.from=StringUtilitiesTest
3
-dependency1.to=StringUtilities
2
+dependency1.from=MathUtilitiesTest
3
+dependency1.to=MathUtilities
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=BonusTest
6
-dependency2.to=Bonus
5
+dependency2.from=StringUtilitiesTest
6
+dependency2.to=StringUtilities
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=MathUtilitiesTest
9
-dependency3.to=MathUtilities
10
-dependency3.type=UsesDependency
11 8
 editor.fx.0.height=722
12 9
 editor.fx.0.width=876
13
-editor.fx.0.x=158
14
-editor.fx.0.y=216
10
+editor.fx.0.x=173
11
+editor.fx.0.y=121
15 12
 objectbench.height=164
16 13
 objectbench.width=669
17 14
 package.divider.horizontal=0.6
@@ -22,7 +19,7 @@ package.editor.x=557
22 19
 package.editor.y=43
23 20
 package.frame.height=779
24 21
 package.frame.width=693
25
-package.numDependencies=3
22
+package.numDependencies=2
26 23
 package.numTargets=6
27 24
 package.showExtends=true
28 25
 package.showUses=true
@@ -40,20 +37,19 @@ target1.width=110
40 37
 target1.x=110
41 38
 target1.y=150
42 39
 target2.height=50
43
-target2.name=BonusTest
40
+target2.name=LoopFunTest
44 41
 target2.showInterface=false
45 42
 target2.type=UnitTestTargetJunit4
46
-target2.width=80
47
-target2.x=120
48
-target2.y=270
49
-target3.association=BonusTest
43
+target2.width=110
44
+target2.x=10
45
+target2.y=240
50 46
 target3.height=50
51
-target3.name=Bonus
47
+target3.name=LoopFun
52 48
 target3.showInterface=false
53 49
 target3.type=ClassTarget
54 50
 target3.width=80
55
-target3.x=90
56
-target3.y=300
51
+target3.x=200
52
+target3.y=210
57 53
 target4.association=MathUtilitiesTest
58 54
 target4.height=50
59 55
 target4.name=MathUtilities