Jose Bedolla 6 年前
父节点
当前提交
eb770cb1d0
共有 4 个文件被更改,包括 64 次插入28 次删除
  1. 24
    3
      LoopFun.java
  2. 14
    5
      MathUtilities.java
  3. 9
    2
      StringUtilities.java
  4. 17
    18
      package.bluej

+ 24
- 3
LoopFun.java 查看文件

@@ -1,3 +1,6 @@
1
+//Did not finish the last test 
2
+
3
+
1 4
 public class LoopFun
2 5
 {
3 6
 
@@ -8,7 +11,15 @@ public class LoopFun
8 11
        * @return the factorial of the number
9 12
        */
10 13
       public int factorial(int number){
11
-          return -1;
14
+          int count;
15
+          if(number==0 || number==1)
16
+          {
17
+          return 1;
18
+            }
19
+            count = factorial(number-1)*number;
20
+          return count;
21
+          
22
+        
12 23
       }
13 24
 
14 25
       /**
@@ -19,7 +30,8 @@ public class LoopFun
19 30
        * @return Upper case string of the first letter of each word
20 31
        */
21 32
       public String acronym(String phrase) {
22
-          return null;
33
+          String needed = phrase.replaceAll("\\B.|\\P{L}","").toUpperCase();
34
+          return needed;
23 35
       }
24 36
 
25 37
       /**
@@ -35,6 +47,15 @@ public class LoopFun
35 47
        * @return the encrypted string by shifting each character by three character
36 48
        */
37 49
       public String encrypt(String word) {
38
-          return null;
50
+       String alpha = "abcdefghijklmnopqrstuvwxyz";
51
+       String table = alpha + alpha + alpha;
52
+       int index= table.indexOf(word);
53
+       if(index!=-1)
54
+       {
55
+       // word = table.charAt(index + word);
56
+        }
57
+
58
+
59
+          return word;
39 60
       }
40 61
 }

+ 14
- 5
MathUtilities.java 查看文件

@@ -6,7 +6,8 @@ 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 sumOfNum = num1 + num2;
10
+      return sumOfNum;
10 11
   }
11 12
 
12 13
   /**
@@ -16,7 +17,8 @@ public class MathUtilities{
16 17
    * @return the sum of the two numbers
17 18
    */
18 19
   public double add(double num1, double num2){
19
-      return -1;
20
+      double sumOfNum = num1 + num2;
21
+      return sumOfNum;
20 22
   }
21 23
 
22 24
   /**
@@ -25,7 +27,9 @@ public class MathUtilities{
25 27
    * @return the half of the number in double
26 28
    */
27 29
   public double half(int number) {
28
-      return -1;
30
+      double divide = number / 2.0;
31
+      System.out.println("number : "+divide);
32
+      return divide;
29 33
   }
30 34
 
31 35
   /**
@@ -34,7 +38,11 @@ public class MathUtilities{
34 38
    * @return true if the number is odd, false if it is even
35 39
    */
36 40
   public boolean isOdd(int number){
37
-      return false;
41
+      if(number%2==0)
42
+      {
43
+       return false; 
44
+      }
45
+      return true;
38 46
   }
39 47
 
40 48
 
@@ -44,7 +52,8 @@ public class MathUtilities{
44 52
    * @return the result of the number multiply by itself
45 53
    */
46 54
   public int square(int number) {
47
-      return -1;
55
+      int multiply = number * number;
56
+      return multiply;
48 57
   }
49 58
 
50 59
 }

+ 9
- 2
StringUtilities.java 查看文件

@@ -1,13 +1,20 @@
1
+// removeCharacter was not completed
1 2
 public class StringUtilities {
2 3
    public Character getMiddleCharacter(String word){
3
-       return null;
4
+       int length = word.length();
5
+       String getMiddle = word.substring(length/2-1, length/2+2);
6
+       char o = getMiddle.charAt(1);
7
+       return o;
4 8
    }
5 9
    
6 10
    public String removeCharacter(String value, char charToRemove){
11
+       
12
+      // char remove = value.replaceAll(charToRemove,"");
7 13
      return null;  
8 14
    }
9 15
    
10 16
    public String getLastWord(String value) {
11
-       return null;
17
+       String last = value.substring(value.lastIndexOf(" ")+1);
18
+       return last;
12 19
    }
13 20
 }

+ 17
- 18
package.bluej 查看文件

@@ -2,25 +2,25 @@
2 2
 dependency1.from=StringUtilitiesTest
3 3
 dependency1.to=StringUtilities
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=BonusTest
6
-dependency2.to=Bonus
5
+dependency2.from=LoopFunTest
6
+dependency2.to=LoopFun
7 7
 dependency2.type=UsesDependency
8 8
 dependency3.from=MathUtilitiesTest
9 9
 dependency3.to=MathUtilities
10 10
 dependency3.type=UsesDependency
11 11
 editor.fx.0.height=722
12 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=-278
14
+editor.fx.0.y=-1057
15
+objectbench.height=151
16 16
 objectbench.width=669
17 17
 package.divider.horizontal=0.6
18
-package.divider.vertical=0.7628294036061026
19
-package.editor.height=543
18
+package.divider.vertical=0.7627627627627628
19
+package.editor.height=501
20 20
 package.editor.width=567
21
-package.editor.x=557
22
-package.editor.y=43
23
-package.frame.height=779
21
+package.editor.x=644
22
+package.editor.y=-1057
23
+package.frame.height=724
24 24
 package.frame.width=693
25 25
 package.numDependencies=3
26 26
 package.numTargets=6
@@ -40,20 +40,19 @@ target1.width=110
40 40
 target1.x=110
41 41
 target1.y=150
42 42
 target2.height=50
43
-target2.name=BonusTest
43
+target2.name=LoopFunTest
44 44
 target2.showInterface=false
45 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=240
50 49
 target3.height=50
51
-target3.name=Bonus
50
+target3.name=LoopFun
52 51
 target3.showInterface=false
53 52
 target3.type=ClassTarget
54 53
 target3.width=80
55
-target3.x=90
56
-target3.y=300
54
+target3.x=200
55
+target3.y=210
57 56
 target4.association=MathUtilitiesTest
58 57
 target4.height=50
59 58
 target4.name=MathUtilities