John Kim 6 anni fa
parent
commit
0694d31ff0

BIN
Factorial.class Vedi File


+ 5
- 0
Factorial.ctxt Vedi File

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

+ 7
- 1
Factorial.java Vedi File

6
 public class Factorial {
6
 public class Factorial {
7
 
7
 
8
     public BigInteger factorialOf(Integer value){
8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+        
10
+        BigInteger factorial = new BigInteger(value.toString()); 
11
+        
12
+        for (int i = 1; i < value; i++) {
13
+            factorial = factorial.multiply(BigInteger.valueOf(i));
14
+        }
15
+        return factorial;
10
     }
16
     }
11
 
17
 
12
 }
18
 }

BIN
FactorialTest.class Vedi File


+ 7
- 0
FactorialTest.ctxt Vedi File

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 Vedi File


+ 11
- 0
IntegerPrinter.ctxt Vedi File

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

+ 3
- 3
IntegerPrinter.java Vedi File

4
 public class IntegerPrinter {
4
 public class IntegerPrinter {
5
 
5
 
6
     public String printIntegerAsBinary(int value){
6
     public String printIntegerAsBinary(int value){
7
-        return null;
7
+        return Integer.toBinaryString(value);
8
     }
8
     }
9
 
9
 
10
     public String printIntegerAsOctal(int value){
10
     public String printIntegerAsOctal(int value){
11
-        return null;
11
+        return Integer.toOctalString(value);
12
     }
12
     }
13
 
13
 
14
     public String printIntegerAsHexadecimal(int value){
14
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
15
+        return Integer.toHexString(value);
16
     }
16
     }
17
 
17
 
18
     public static void main(String[] args){
18
     public static void main(String[] args){

BIN
IntegerPrinterTest.class Vedi File


+ 11
- 0
IntegerPrinterTest.ctxt Vedi File

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 Vedi File


+ 7
- 0
LargestInteger.ctxt Vedi File

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

+ 19
- 4
LargestInteger.java Vedi File

2
 
2
 
3
 
3
 
4
 public class LargestInteger {
4
 public class LargestInteger {
5
-
6
-    public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
5
+    
6
+    public Integer findLargestNumberUsingConditional(Integer[] integers){        
7
+        
8
+        Integer max = new Integer(Integer.MIN_VALUE);
9
+        
10
+        for (int i = 0; i <integers.length; i++) {
11
+       
12
+            if (max < integers[i]) {
13
+                max = integers[i];
14
+            }
15
+        }
16
+        return max;
8
     }
17
     }
9
 
18
 
10
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
19
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
20
+        
21
+        int max = Integer.MIN_VALUE;
22
+        
23
+        for (int i = 0; i < integers.length; i++) {
24
+            max = Math.max(max, integers[i]);
25
+        }
26
+        return max;
12
     }
27
     }
13
 }
28
 }

BIN
LargestIntegerTest.class Vedi File


+ 9
- 0
LargestIntegerTest.ctxt Vedi File

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 Vedi File


+ 9
- 0
NormalizeAngle.ctxt Vedi File

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 Vedi File

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

BIN
NormalizeAngleTest.class Vedi File


+ 9
- 0
NormalizeAngleTest.ctxt Vedi File

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 Vedi File


+ 3
- 0
ShortCalculator.ctxt Vedi File

1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+numComments=1

BIN
ShortCalculatorTest.class Vedi File


+ 3
- 0
ShortCalculatorTest.ctxt Vedi File

1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+numComments=1