#26 Kris Blassingame

Open
KrisBlassingame wants to merge 2 commits from KrisBlassingame/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

+ 9
- 6
Factorial.java View File

@@ -1,12 +1,15 @@
1
- 
2
-
3
-
4 1
 import java.math.BigInteger;
5 2
 
6 3
 public class Factorial {
7
-
4
+    
8 5
     public BigInteger factorialOf(Integer value){
9
-        return null;
10
-    }
11 6
 
7
+        BigInteger bi = BigInteger.valueOf(value);
8
+
9
+        for (int i = 1; i < value; i++) {
10
+            bi = bi.multiply(BigInteger.valueOf(i));
11
+        }
12
+        return bi;
13
+    }
12 14
 }
15
+

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

+ 11
- 5
IntegerPrinter.java View File

@@ -1,18 +1,24 @@
1
- 
2
-
1
+import java.util.*;
3 2
 
4 3
 public class IntegerPrinter {
5 4
 
6 5
     public String printIntegerAsBinary(int value){
7
-        return null;
6
+        String binary = Integer.toBinaryString(value);
7
+        
8
+        //Integer i = new Integer(20);
9
+        //String binary = Integer.toBinaryString(i);
10
+        //System.out.println("Binary value: "+binary);
11
+        return binary; 
8 12
     }
9 13
 
10 14
     public String printIntegerAsOctal(int value){
11
-        return null;
15
+        String binary = Integer.toOctalString(value);
16
+        return binary;
12 17
     }
13 18
 
14 19
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
20
+        String binary = Integer.toHexString(value);
21
+        return binary;
16 22
     }
17 23
 
18 24
     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

+ 9
- 5
LargestInteger.java View File

@@ -1,13 +1,17 @@
1
- 
2
-
1
+import java.util.*;
3 2
 
4 3
 public class LargestInteger {
5
-
6 4
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
5
+        int highestNum = integers[0];
6
+        for (int i = 0; i < integers.length; i++){
7
+            if (i > highestNum){
8
+                highestNum = integers[i];
9
+            }
10
+        }
11
+        return highestNum;
8 12
     }
9 13
 
10 14
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
15
+        return Math.max(integers[0],(Math.max(integers[1],integers[2])));
12 16
     }
13 17
 }

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

+ 2
- 2
NormalizeAngle.java View File

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


+ 13
- 0
ShortCalculator.ctxt View File

@@ -0,0 +1,13 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=x\ y
4
+comment1.target=short\ add(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\ remainder(short,\ short)
13
+numComments=6

+ 24
- 1
ShortCalculator.java View File

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

BIN
ShortCalculatorTest.class View File


+ 13
- 0
ShortCalculatorTest.ctxt View File

@@ -0,0 +1,13 @@
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
+numComments=4

+ 39
- 2
ShortCalculatorTest.java View File

@@ -1,5 +1,42 @@
1
- 
2 1
 
3 2
 
4
-public class ShortCalculatorTest {
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+/**
9
+ * The test class ShortCalculatorTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class ShortCalculatorTest
15
+{
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
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
5 42
 }

+ 70
- 54
package.bluej View File

@@ -5,28 +5,28 @@ dependency1.type=UsesDependency
5 5
 dependency2.from=NormalizeAngleTest
6 6
 dependency2.to=NormalizeAngle
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=FactorialTest
12
+dependency4.to=Factorial
13 13
 dependency4.type=UsesDependency
14
-editor.fx.0.height=0
14
+editor.fx.0.height=22
15 15
 editor.fx.0.width=0
16
-editor.fx.0.x=0
17
-editor.fx.0.y=0
16
+editor.fx.0.x=40
17
+editor.fx.0.y=813
18 18
 objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
19
+objectbench.width=608
20
+package.divider.horizontal=0.606508875739645
21 21
 package.divider.vertical=0.837593984962406
22 22
 package.editor.height=550
23
-package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
23
+package.editor.width=908
24
+package.editor.x=534
25
+package.editor.y=-865
26 26
 package.frame.height=723
27
-package.frame.width=1094
27
+package.frame.width=1034
28 28
 package.numDependencies=4
29
-package.numTargets=10
29
+package.numTargets=12
30 30
 package.showExtends=true
31 31
 package.showUses=true
32 32
 project.charset=UTF-8
@@ -36,72 +36,88 @@ readme.width=47
36 36
 readme.x=10
37 37
 readme.y=10
38 38
 target1.height=50
39
-target1.name=Factorial
39
+target1.name=NormalizeAngle
40 40
 target1.showInterface=false
41 41
 target1.type=ClassTarget
42
-target1.width=80
43
-target1.x=160
44
-target1.y=10
42
+target1.width=120
43
+target1.x=520
44
+target1.y=20
45 45
 target10.height=50
46
-target10.name=IntegerPrinterTest
46
+target10.name=ShortCalculatorTest
47 47
 target10.showInterface=false
48 48
 target10.type=UnitTestTargetJunit4
49
-target10.width=140
50
-target10.x=10
51
-target10.y=370
49
+target10.width=120
50
+target10.x=370
51
+target10.y=10
52
+target11.height=50
53
+target11.name=NormalizeAngleTest
54
+target11.showInterface=false
55
+target11.type=UnitTestTargetJunit4
56
+target11.width=150
57
+target11.x=580
58
+target11.y=20
59
+target12.association=stuffTest
60
+target12.height=50
61
+target12.name=stuff
62
+target12.showInterface=false
63
+target12.type=ClassTarget
64
+target12.width=80
65
+target12.x=440
66
+target12.y=300
67
+target2.association=ShortCalculatorTest
52 68
 target2.height=50
53
-target2.name=NormalizeAngle
69
+target2.name=ShortCalculator
54 70
 target2.showInterface=false
55 71
 target2.type=ClassTarget
56 72
 target2.width=120
57
-target2.x=70
58
-target2.y=70
73
+target2.x=340
74
+target2.y=40
59 75
 target3.height=50
60
-target3.name=IntegerPrinter
76
+target3.name=LargestInteger
61 77
 target3.showInterface=false
62 78
 target3.type=ClassTarget
63
-target3.width=110
79
+target3.width=120
64 80
 target3.x=10
65
-target3.y=130
81
+target3.y=190
66 82
 target4.height=50
67
-target4.name=ShortCalculator
83
+target4.name=FactorialTest
68 84
 target4.showInterface=false
69
-target4.type=ClassTarget
70
-target4.width=120
71
-target4.x=130
72
-target4.y=130
85
+target4.type=UnitTestTargetJunit4
86
+target4.width=110
87
+target4.x=210
88
+target4.y=10
73 89
 target5.height=50
74
-target5.name=LargestInteger
90
+target5.name=IntegerPrinterTest
75 91
 target5.showInterface=false
76
-target5.type=ClassTarget
77
-target5.width=120
78
-target5.x=10
79
-target5.y=190
92
+target5.type=UnitTestTargetJunit4
93
+target5.width=140
94
+target5.x=50
95
+target5.y=130
80 96
 target6.height=50
81
-target6.name=LargestIntegerTest
97
+target6.name=Factorial
82 98
 target6.showInterface=false
83
-target6.type=UnitTestTargetJunit4
84
-target6.width=140
85
-target6.x=250
86
-target6.y=190
99
+target6.type=ClassTarget
100
+target6.width=80
101
+target6.x=160
102
+target6.y=10
87 103
 target7.height=50
88
-target7.name=ShortCalculatorTest
104
+target7.name=IntegerPrinter
89 105
 target7.showInterface=false
90 106
 target7.type=ClassTarget
91
-target7.width=150
107
+target7.width=110
92 108
 target7.x=10
93
-target7.y=250
109
+target7.y=130
94 110
 target8.height=50
95
-target8.name=NormalizeAngleTest
111
+target8.name=stuffTest
96 112
 target8.showInterface=false
97 113
 target8.type=UnitTestTargetJunit4
98
-target8.width=150
99
-target8.x=10
100
-target8.y=310
114
+target8.width=80
115
+target8.x=470
116
+target8.y=270
101 117
 target9.height=50
102
-target9.name=FactorialTest
118
+target9.name=LargestIntegerTest
103 119
 target9.showInterface=false
104 120
 target9.type=UnitTestTargetJunit4
105
-target9.width=110
106
-target9.x=410
107
-target9.y=260
121
+target9.width=140
122
+target9.x=100
123
+target9.y=200