#28 Updated Commit

Open
jdot2791 wants to merge 2 commits from jdot2791/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(int)
5
+numComments=2

+ 9
- 2
Factorial.java View File

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

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

+ 0
- 1
FactorialTest.java View File

@@ -4,7 +4,6 @@
4 4
 import org.junit.Assert;
5 5
 import org.junit.Before;
6 6
 import org.junit.Test;
7
-
8 7
 import java.math.BigInteger;
9 8
 
10 9
 public class FactorialTest {

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

+ 4
- 4
IntegerPrinter.java View File

@@ -3,16 +3,16 @@
3 3
 
4 4
 public class IntegerPrinter {
5 5
 
6
-    public String printIntegerAsBinary(int value){
7
-        return null;
6
+    public String printIntegerAsBinary(int value){                
7
+        return Integer.toBinaryString(value);
8 8
     }
9 9
 
10 10
     public String printIntegerAsOctal(int value){
11
-        return null;
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){

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

+ 16
- 3
LargestInteger.java View File

@@ -1,13 +1,26 @@
1
- 
1
+import java.lang.Math;
2
+import java.util.Arrays;
2 3
 
3 4
 
4 5
 public class LargestInteger {
5 6
 
6 7
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
8
+        
9
+        int largest = integers[0];
10
+        
11
+        for(int num : integers){
12
+            largest = num;
13
+        }
14
+        
15
+        return largest;
8 16
     }
9 17
 
10 18
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
19
+                
20
+        int[] tab = {};
21
+        int largest = Arrays.stream(tab).max().getAsInt();
22
+        
23
+        return largest;
24
+
12 25
     }
13 26
 }

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

+ 0
- 3
LargestIntegerTest.java View File

@@ -1,6 +1,3 @@
1
- 
2
-
3
-
4 1
 import org.junit.Assert;
5 2
 import org.junit.Before;
6 3
 import org.junit.Test;

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

+ 4
- 3
NormalizeAngle.java View File

@@ -1,14 +1,15 @@
1
- 
1
+ import java.lang.Math;
2 2
 
3 3
 
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        angle %= 360;
8
+        return angle;
8 9
     }
9 10
 
10 11
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
12
+        return Math.floorMod(integer, 360);
12 13
     }
13 14
 
14 15
     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


+ 15
- 0
ShortCalculator.ctxt View File

@@ -0,0 +1,15 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=x\ y
4
+comment1.target=void\ findRange(short,\ short)
5
+comment2.params=x\ y
6
+comment2.target=int\ calculateSum(short,\ short)
7
+comment3.params=x\ y
8
+comment3.target=int\ calculateDifference(short,\ short)
9
+comment4.params=x\ y
10
+comment4.target=int\ calculateProduct(short,\ short)
11
+comment5.params=x\ y
12
+comment5.target=int\ calculateQuotient(short,\ short)
13
+comment6.params=x\ y
14
+comment6.target=int\ calculateRemainder(short,\ short)
15
+numComments=7

+ 32
- 0
ShortCalculator.java View File

@@ -2,4 +2,36 @@
2 2
 
3 3
 
4 4
 public class ShortCalculator {
5
+    
6
+    int firstShortVar = 0;
7
+    int secondShortVar = 0;
8
+    
9
+    public void findRange(short x, short y){
10
+        if(0 <= x && x <= 65535){
11
+            firstShortVar = x;           
12
+        }
13
+        if(0 <= y && y <= 65535){
14
+            secondShortVar = y;   
15
+        } 
16
+    }
17
+
18
+    public int calculateSum(short x, short y){               
19
+        return firstShortVar + secondShortVar;                
20
+    }
21
+    
22
+    public int calculateDifference(short x, short y){      
23
+        return firstShortVar - secondShortVar;                
24
+    }
25
+    
26
+    public int calculateProduct(short x, short y){     
27
+        return firstShortVar * secondShortVar;                
28
+    }
29
+    
30
+    public int calculateQuotient(short x, short y){     
31
+        return firstShortVar / secondShortVar;                
32
+    }
33
+    
34
+    public int calculateRemainder(short x, short y){       
35
+        return firstShortVar % secondShortVar;                
36
+    }
5 37
 }

+ 0
- 5
ShortCalculatorTest.java View File

@@ -1,5 +0,0 @@
1
- 
2
-
3
-
4
-public class ShortCalculatorTest {
5
-}

+ 38
- 45
package.bluej View File

@@ -1,32 +1,32 @@
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=IntegerPrinterTest
6
+dependency2.to=IntegerPrinter
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=FactorialTest
9
-dependency3.to=Factorial
8
+dependency3.from=LargestIntegerTest
9
+dependency3.to=LargestInteger
10 10
 dependency3.type=UsesDependency
11
-dependency4.from=IntegerPrinterTest
12
-dependency4.to=IntegerPrinter
11
+dependency4.from=FactorialTest
12
+dependency4.to=Factorial
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
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
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
14
+editor.fx.0.height=709
15
+editor.fx.0.width=979
16
+editor.fx.0.x=212
17
+editor.fx.0.y=23
18
+objectbench.height=98
19
+objectbench.width=406
20
+package.divider.horizontal=0.6002906976744186
21
+package.divider.vertical=0.8387096774193549
22
+package.editor.height=539
23
+package.editor.width=582
24
+package.editor.x=58
25
+package.editor.y=23
26
+package.frame.height=709
27
+package.frame.width=708
28 28
 package.numDependencies=4
29
-package.numTargets=10
29
+package.numTargets=9
30 30
 package.showExtends=true
31 31
 package.showUses=true
32 32
 project.charset=UTF-8
@@ -42,13 +42,6 @@ target1.type=ClassTarget
42 42
 target1.width=80
43 43
 target1.x=160
44 44
 target1.y=10
45
-target10.height=50
46
-target10.name=IntegerPrinterTest
47
-target10.showInterface=false
48
-target10.type=UnitTestTargetJunit4
49
-target10.width=140
50
-target10.x=10
51
-target10.y=370
52 45
 target2.height=50
53 46
 target2.name=NormalizeAngle
54 47
 target2.showInterface=false
@@ -68,15 +61,15 @@ target4.name=ShortCalculator
68 61
 target4.showInterface=false
69 62
 target4.type=ClassTarget
70 63
 target4.width=120
71
-target4.x=130
72
-target4.y=130
64
+target4.x=250
65
+target4.y=110
73 66
 target5.height=50
74 67
 target5.name=LargestInteger
75 68
 target5.showInterface=false
76 69
 target5.type=ClassTarget
77 70
 target5.width=120
78
-target5.x=10
79
-target5.y=190
71
+target5.x=230
72
+target5.y=370
80 73
 target6.height=50
81 74
 target6.name=LargestIntegerTest
82 75
 target6.showInterface=false
@@ -85,23 +78,23 @@ target6.width=140
85 78
 target6.x=250
86 79
 target6.y=190
87 80
 target7.height=50
88
-target7.name=ShortCalculatorTest
81
+target7.name=NormalizeAngleTest
89 82
 target7.showInterface=false
90
-target7.type=ClassTarget
83
+target7.type=UnitTestTargetJunit4
91 84
 target7.width=150
92 85
 target7.x=10
93
-target7.y=250
86
+target7.y=310
94 87
 target8.height=50
95
-target8.name=NormalizeAngleTest
88
+target8.name=FactorialTest
96 89
 target8.showInterface=false
97 90
 target8.type=UnitTestTargetJunit4
98
-target8.width=150
99
-target8.x=10
100
-target8.y=310
91
+target8.width=110
92
+target8.x=410
93
+target8.y=260
101 94
 target9.height=50
102
-target9.name=FactorialTest
95
+target9.name=IntegerPrinterTest
103 96
 target9.showInterface=false
104 97
 target9.type=UnitTestTargetJunit4
105
-target9.width=110
106
-target9.x=410
107
-target9.y=260
98
+target9.width=140
99
+target9.x=40
100
+target9.y=400