Kris Blassingame 6 years ago
parent
commit
e669646ade

BIN
Factorial.class View File


+ 9
- 3
Factorial.java View File

@@ -1,9 +1,15 @@
1 1
 import java.math.BigInteger;
2 2
 
3 3
 public class Factorial {
4
-
4
+    
5 5
     public BigInteger factorialOf(Integer value){
6
-        return null;
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;
7 13
     }
14
+}
8 15
 
9
-}

BIN
LargestInteger.class View File


+ 8
- 6
LargestInteger.java View File

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

BIN
NormalizeAngle.class View File


+ 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
ShortCalculator.class View File


+ 11
- 1
ShortCalculator.ctxt View File

@@ -1,3 +1,13 @@
1 1
 #BlueJ class context
2 2
 comment0.target=ShortCalculator
3
-numComments=1
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


+ 11
- 1
ShortCalculatorTest.ctxt View File

@@ -1,3 +1,13 @@
1 1
 #BlueJ class context
2 2
 comment0.target=ShortCalculatorTest
3
-numComments=1
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=637
20
-package.divider.horizontal=0.5996275605214153
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