#32 dmjpub

Open
dmjpub wants to merge 1 commits from dmjpub/ZCW-BasicComputations-BlueJ:master into master

BIN
Factorial.class View File


+ 5
- 0
Factorial.ctxt View File

@@ -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

+ 6
- 2
Factorial.java View File

@@ -4,9 +4,13 @@
4 4
 import java.math.BigInteger;
5 5
 
6 6
 public class Factorial {
7
-
7
+    
8 8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+         BigInteger result = BigInteger.ONE;
10
+    for (; value > 1; value--) {
11
+        result = result.multiply(BigInteger.valueOf(value));
12
+    }
13
+    return result;
10 14
     }
11 15
 
12 16
 }

BIN
FactorialTest.class View File


+ 7
- 0
FactorialTest.ctxt View File

@@ -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 View File


+ 11
- 0
IntegerPrinter.ctxt View File

@@ -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
- 4
IntegerPrinter.java View File

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

BIN
IntegerPrinterTest.class View File


+ 11
- 0
IntegerPrinterTest.ctxt View File

@@ -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 View File


+ 7
- 0
LargestInteger.ctxt View File

@@ -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

+ 21
- 3
LargestInteger.java View File

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

BIN
LargestIntegerTest.class View File


+ 9
- 0
LargestIntegerTest.ctxt View File

@@ -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 View File


+ 9
- 0
NormalizeAngle.ctxt View File

@@ -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

+ 12
- 3
NormalizeAngle.java View File

@@ -2,13 +2,22 @@
2 2
 
3 3
 
4 4
 public class NormalizeAngle {
5
-
5
+    private Integer newAngle;
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        // reduce the angle  
8
+        newAngle =  angle % 360; 
9
+
10
+        // force into the minimum absolute value residue class, so that -180 < angle <= 180  
11
+        if (newAngle > 360) { 
12
+        newAngle -= 360; }
13
+        else if(newAngle < 0) {newAngle += 360;}
14
+       
15
+        return newAngle;
8 16
     }
9 17
 
10 18
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
19
+        newAngle = Math.floorMod(integer, 360);
20
+        return newAngle;
12 21
     }
13 22
 
14 23
     public static void main(String[] args){

BIN
NormalizeAngleTest.class View File


+ 9
- 0
NormalizeAngleTest.ctxt View File

@@ -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 View File


+ 3
- 0
ShortCalculator.ctxt View File

@@ -0,0 +1,3 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+numComments=1

BIN
ShortCalculatorTest.class View File


+ 3
- 0
ShortCalculatorTest.ctxt View File

@@ -0,0 +1,3 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+numComments=1

+ 8
- 8
package.bluej View File

@@ -15,15 +15,15 @@ editor.fx.0.height=0
15 15
 editor.fx.0.width=0
16 16
 editor.fx.0.x=0
17 17
 editor.fx.0.y=0
18
-objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
18
+objectbench.height=98
19
+objectbench.width=637
20
+package.divider.horizontal=0.5996275605214153
21
+package.divider.vertical=0.8387096774193549
22
+package.editor.height=539
23 23
 package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
24
+package.editor.x=186
25
+package.editor.y=23
26
+package.frame.height=709
27 27
 package.frame.width=1094
28 28
 package.numDependencies=4
29 29
 package.numTargets=10