Clement Ojie hace 6 años
padre
commit
739abdfda2

BIN
Factorial.class Ver fichero


+ 5
- 0
Factorial.ctxt Ver fichero

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=Factorial
3
+comment1.params=value
4
+comment1.target=java.math.BigInteger\ factorialOf(java.lang.Integer)
5
+numComments=2

+ 11
- 4
Factorial.java Ver fichero

@@ -1,4 +1,3 @@
1
- 
2 1
 
3 2
 
4 3
 import java.math.BigInteger;
@@ -6,7 +5,15 @@ import java.math.BigInteger;
6 5
 public class Factorial {
7 6
 
8 7
     public BigInteger factorialOf(Integer value){
9
-        return null;
10
-    }
8
+        BigInteger answer = new BigInteger("1");
9
+        BigInteger big = BigInteger.valueOf(value.intValue());
10
+        value = big.intValue();
11
+        int x = big.intValue();
12
+        for ( x = 1; x <= value; x++){
13
+
14
+            answer = answer.multiply(BigInteger.valueOf(x)); 
11 15
 
12
-}
16
+        }
17
+        return answer;
18
+    }
19
+}

BIN
FactorialTest.class Ver fichero


+ 7
- 0
FactorialTest.ctxt Ver fichero

@@ -0,0 +1,7 @@
1
+#BlueJ class context
2
+comment0.target=FactorialTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ factorialOfTest()
7
+numComments=3

BIN
IntegerPrinter.class Ver fichero


+ 11
- 0
IntegerPrinter.ctxt Ver fichero

@@ -0,0 +1,11 @@
1
+#BlueJ class context
2
+comment0.target=IntegerPrinter
3
+comment1.params=value
4
+comment1.target=java.lang.String\ printIntegerAsBinary(int)
5
+comment2.params=value
6
+comment2.target=java.lang.String\ printIntegerAsOctal(int)
7
+comment3.params=value
8
+comment3.target=java.lang.String\ printIntegerAsHexadecimal(int)
9
+comment4.params=args
10
+comment4.target=void\ main(java.lang.String[])
11
+numComments=5

+ 9
- 9
IntegerPrinter.java Ver fichero

@@ -1,21 +1,21 @@
1
- 
2
-
1
+import java.util.Scanner;
3 2
 
4 3
 public class IntegerPrinter {
5
-
4
+    
6 5
     public String printIntegerAsBinary(int value){
7
-        return null;
6
+        
7
+        return Integer.toBinaryString(value);
8 8
     }
9
-
10
-    public String printIntegerAsOctal(int value){
11
-        return null;
9
+    
10
+        public String printIntegerAsOctal(int value){
11
+        return Integer.toOctalString(value);
12 12
     }
13 13
 
14 14
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
15
+        return Integer.toHexString(value);
16 16
     }
17 17
 
18 18
     public static void main(String[] args){
19
-
19
+        
20 20
     }
21 21
 }

BIN
IntegerPrinterTest.class Ver fichero


+ 11
- 0
IntegerPrinterTest.ctxt Ver fichero

@@ -0,0 +1,11 @@
1
+#BlueJ class context
2
+comment0.target=IntegerPrinterTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ printIntegerAsBinaryTest()
7
+comment3.params=
8
+comment3.target=void\ printIntegerAsHexadecimal()
9
+comment4.params=
10
+comment4.target=void\ printIntegerAsOctalTest()
11
+numComments=5

BIN
LargestInteger.class Ver fichero


+ 7
- 0
LargestInteger.ctxt Ver fichero

@@ -0,0 +1,7 @@
1
+#BlueJ class context
2
+comment0.target=LargestInteger
3
+comment1.params=integers
4
+comment1.target=java.lang.Integer\ findLargestNumberUsingConditional(java.lang.Integer[])
5
+comment2.params=integers
6
+comment2.target=java.lang.Integer\ findLargestNumberUsingMathMax(java.lang.Integer[])
7
+numComments=3

+ 14
- 5
LargestInteger.java Ver fichero

@@ -1,13 +1,22 @@
1
- 
2
-
3 1
 
4 2
 public class LargestInteger {
5
-
6 3
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
4
+        
5
+        int great = integers [0];
6
+        for (int x = 0; x < integers.length; x++){
7
+            
8
+            if (great < integers[x]){
9
+                
10
+                great = integers[x];
11
+
12
+            }
13
+
14
+        }
15
+        return great;
8 16
     }
9 17
 
10 18
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
19
+        return Math.max(integers[0], Math.max(integers[1],integers[2]));
20
+
12 21
     }
13 22
 }

BIN
LargestIntegerTest.class Ver fichero


+ 9
- 0
LargestIntegerTest.ctxt Ver fichero

@@ -0,0 +1,9 @@
1
+#BlueJ class context
2
+comment0.target=LargestIntegerTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ findLargestNumberUsingConditionalTest()
7
+comment3.params=
8
+comment3.target=void\ findLargestNumberUsingMathMaxTest()
9
+numComments=4

BIN
NormalizeAngle.class Ver fichero


+ 9
- 0
NormalizeAngle.ctxt Ver fichero

@@ -0,0 +1,9 @@
1
+#BlueJ class context
2
+comment0.target=NormalizeAngle
3
+comment1.params=angle
4
+comment1.target=java.lang.Integer\ normalizeValueUsingModulo(java.lang.Integer)
5
+comment2.params=integer
6
+comment2.target=java.lang.Integer\ normalizeValueUsingFloorMod(java.lang.Integer)
7
+comment3.params=args
8
+comment3.target=void\ main(java.lang.String[])
9
+numComments=4

+ 2
- 2
NormalizeAngle.java Ver fichero

@@ -4,11 +4,11 @@
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        return angle % 360 ;
8 8
     }
9 9
 
10 10
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
11
+        return Math.floorMod(integer,360);
12 12
     }
13 13
 
14 14
     public static void main(String[] args){

BIN
NormalizeAngleTest.class Ver fichero


+ 9
- 0
NormalizeAngleTest.ctxt Ver fichero

@@ -0,0 +1,9 @@
1
+#BlueJ class context
2
+comment0.target=NormalizeAngleTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ normalizeValueUsingModuloTest()
7
+comment3.params=
8
+comment3.target=void\ normalizeValueUsingFloorModTest()
9
+numComments=4

BIN
ShortCalculator.class Ver fichero


+ 13
- 0
ShortCalculator.ctxt Ver fichero

@@ -0,0 +1,13 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=x\ y
4
+comment1.target=short\ sum(short,\ short)
5
+comment2.params=x\ y
6
+comment2.target=short\ subtract(short,\ short)
7
+comment3.params=x\ y
8
+comment3.target=short\ multiply(short,\ short)
9
+comment4.params=x\ y
10
+comment4.target=short\ divide(short,\ short)
11
+comment5.params=x\ y
12
+comment5.target=short\ mod(short,\ short)
13
+numComments=6

+ 26
- 1
ShortCalculator.java Ver fichero

@@ -1,5 +1,30 @@
1
- 
2 1
 
3 2
 
4 3
 public class ShortCalculator {
4
+
5
+    public short sum(short x, short y){
6
+
7
+        return (short) (x + y);
8
+    }
9
+    public short subtract(short x, short y){
10
+    
11
+        return (short) (x - y);
12
+
13
+    }
14
+
15
+    public short multiply(short x, short y){
16
+
17
+        return (short) (x * y);
18
+    }
19
+    public short divide(short x, short y){
20
+    
21
+        return (short) (x / y);
22
+
23
+    }
24
+
25
+    public short mod(short x, short y){
26
+
27
+        return (short) (x % y);
28
+    }
5 29
 }
30
+

BIN
ShortCalculatorTest.class Ver fichero


+ 23
- 0
ShortCalculatorTest.ctxt Ver fichero

@@ -0,0 +1,23 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+comment0.text=\n\ The\ test\ class\ ShortCalculatorTest.\n\n\ @author\ \ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=ShortCalculatorTest()
6
+comment1.text=\n\ Default\ constructor\ for\ test\ class\ ShortCalculatorTest\n
7
+comment2.params=
8
+comment2.target=void\ setUp()
9
+comment2.text=\n\ Sets\ up\ the\ test\ fixture.\n\n\ Called\ before\ every\ test\ case\ method.\n
10
+comment3.params=
11
+comment3.target=void\ tearDown()
12
+comment3.text=\n\ Tears\ down\ the\ test\ fixture.\n\n\ Called\ after\ every\ test\ case\ method.\n
13
+comment4.params=
14
+comment4.target=void\ sum()
15
+comment5.params=
16
+comment5.target=void\ subtract()
17
+comment6.params=
18
+comment6.target=void\ divide()
19
+comment7.params=
20
+comment7.target=void\ multiply()
21
+comment8.params=
22
+comment8.target=void\ mod()
23
+numComments=9

+ 100
- 2
ShortCalculatorTest.java Ver fichero

@@ -1,5 +1,103 @@
1
- 
2 1
 
2
+import static org.junit.Assert.*;
3
+import org.junit.After;
4
+import org.junit.Before;
5
+import org.junit.Test;
3 6
 
4
-public class ShortCalculatorTest {
7
+/**
8
+ * The test class ShortCalculatorTest.
9
+ *
10
+ * @author  (your name)
11
+ * @version (a version number or a date)
12
+ */
13
+public class ShortCalculatorTest
14
+{
15
+    ShortCalculator shortCalculator;
16
+    /**
17
+     * Default constructor for test class ShortCalculatorTest
18
+     */
19
+    public ShortCalculatorTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+        shortCalculator = new ShortCalculator();
32
+    }
33
+
34
+    /**
35
+     * Tears down the test fixture.
36
+     *
37
+     * Called after every test case method.
38
+     */
39
+    @After
40
+    public void tearDown()
41
+    {
42
+    }
43
+
44
+    @Test
45
+    public void sum(){//:Given
46
+        short expected = 20;
47
+
48
+        //:When
49
+        short actual = shortCalculator.sum((short)10 , (short)10);
50
+
51
+        //:Then
52
+        assertEquals( expected, actual);
53
+
54
+    }
55
+
56
+    @Test
57
+    public void subtract(){//:Given
58
+        short expected = 20;
59
+
60
+        //:When
61
+        short actual = shortCalculator.subtract((short)35 , (short)15);
62
+
63
+        //:Then
64
+        assertEquals( expected, actual);
65
+
66
+    }
67
+
68
+    @Test
69
+    public void divide(){//:Given
70
+        short expected = 1;
71
+
72
+        //:When
73
+        short actual = shortCalculator.divide((short)10 , (short)10);
74
+
75
+        //:Then
76
+        assertEquals( expected, actual);
77
+
78
+    }
79
+
80
+    @Test
81
+    public void multiply(){//
82
+        short expected = 100;
83
+
84
+        //:When
85
+        short actual = shortCalculator.multiply((short)20 , (short)5);
86
+
87
+        //:Then
88
+        assertEquals(expected, actual);
89
+
90
+    }
91
+
92
+    @Test
93
+    public void mod(){//:Given
94
+        short expected = 0;
95
+
96
+        //:When
97
+        short actual = shortCalculator.mod((short)10 , (short)10);
98
+
99
+        //:Then
100
+        assertEquals( expected, actual);
101
+
102
+    }
5 103
 }

+ 42
- 38
package.bluej Ver fichero

@@ -1,31 +1,34 @@
1 1
 #BlueJ package file
2
-dependency1.from=LargestIntegerTest
3
-dependency1.to=LargestInteger
2
+dependency1.from=NormalizeAngleTest
3
+dependency1.to=NormalizeAngle
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=NormalizeAngleTest
6
-dependency2.to=NormalizeAngle
5
+dependency2.from=FactorialTest
6
+dependency2.to=Factorial
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=FactorialTest
9
-dependency3.to=Factorial
8
+dependency3.from=IntegerPrinterTest
9
+dependency3.to=IntegerPrinter
10 10
 dependency3.type=UsesDependency
11
-dependency4.from=IntegerPrinterTest
12
-dependency4.to=IntegerPrinter
11
+dependency4.from=LargestIntegerTest
12
+dependency4.to=LargestInteger
13 13
 dependency4.type=UsesDependency
14
-editor.fx.0.height=0
15
-editor.fx.0.width=0
16
-editor.fx.0.x=0
17
-editor.fx.0.y=0
14
+dependency5.from=ShortCalculatorTest
15
+dependency5.to=ShortCalculator
16
+dependency5.type=UsesDependency
17
+editor.fx.0.height=722
18
+editor.fx.0.width=818
19
+editor.fx.0.x=394
20
+editor.fx.0.y=23
18 21
 objectbench.height=101
19
-objectbench.width=1070
22
+objectbench.width=902
20 23
 package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
23
-package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
27
-package.frame.width=1094
28
-package.numDependencies=4
24
+package.divider.vertical=0.815068493150685
25
+package.editor.height=469
26
+package.editor.width=800
27
+package.editor.x=0
28
+package.editor.y=23
29
+package.frame.height=642
30
+package.frame.width=926
31
+package.numDependencies=5
29 32
 package.numTargets=10
30 33
 package.showExtends=true
31 34
 package.showUses=true
@@ -40,22 +43,22 @@ target1.name=Factorial
40 43
 target1.showInterface=false
41 44
 target1.type=ClassTarget
42 45
 target1.width=80
43
-target1.x=160
44
-target1.y=10
46
+target1.x=430
47
+target1.y=280
45 48
 target10.height=50
46 49
 target10.name=IntegerPrinterTest
47 50
 target10.showInterface=false
48 51
 target10.type=UnitTestTargetJunit4
49 52
 target10.width=140
50
-target10.x=10
51
-target10.y=370
53
+target10.x=30
54
+target10.y=100
52 55
 target2.height=50
53 56
 target2.name=NormalizeAngle
54 57
 target2.showInterface=false
55 58
 target2.type=ClassTarget
56 59
 target2.width=120
57
-target2.x=70
58
-target2.y=70
60
+target2.x=580
61
+target2.y=140
59 62
 target3.height=50
60 63
 target3.name=IntegerPrinter
61 64
 target3.showInterface=false
@@ -63,41 +66,42 @@ target3.type=ClassTarget
63 66
 target3.width=110
64 67
 target3.x=10
65 68
 target3.y=130
69
+target4.association=ShortCalculatorTest
66 70
 target4.height=50
67 71
 target4.name=ShortCalculator
68 72
 target4.showInterface=false
69 73
 target4.type=ClassTarget
70 74
 target4.width=120
71
-target4.x=130
72
-target4.y=130
75
+target4.x=180
76
+target4.y=250
73 77
 target5.height=50
74 78
 target5.name=LargestInteger
75 79
 target5.showInterface=false
76 80
 target5.type=ClassTarget
77 81
 target5.width=120
78
-target5.x=10
79
-target5.y=190
82
+target5.x=240
83
+target5.y=120
80 84
 target6.height=50
81 85
 target6.name=LargestIntegerTest
82 86
 target6.showInterface=false
83 87
 target6.type=UnitTestTargetJunit4
84 88
 target6.width=140
85 89
 target6.x=250
86
-target6.y=190
90
+target6.y=90
87 91
 target7.height=50
88 92
 target7.name=ShortCalculatorTest
89 93
 target7.showInterface=false
90
-target7.type=ClassTarget
91
-target7.width=150
92
-target7.x=10
93
-target7.y=250
94
+target7.type=UnitTestTargetJunit4
95
+target7.width=120
96
+target7.x=210
97
+target7.y=220
94 98
 target8.height=50
95 99
 target8.name=NormalizeAngleTest
96 100
 target8.showInterface=false
97 101
 target8.type=UnitTestTargetJunit4
98 102
 target8.width=150
99
-target8.x=10
100
-target8.y=310
103
+target8.x=550
104
+target8.y=120
101 105
 target9.height=50
102 106
 target9.name=FactorialTest
103 107
 target9.showInterface=false