Vincent Sima 6 years ago
parent
commit
d9f5ba627c

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

+ 7
- 1
Factorial.java View File

@@ -6,7 +6,13 @@ import java.math.BigInteger;
6 6
 public class Factorial {
7 7
 
8 8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+        long fact = 1;
10
+        
11
+        for(long i=1; i <= value; i++){
12
+         fact *= i;   
13
+        }
14
+        
15
+        return BigInteger.valueOf(fact);
10 16
     }
11 17
 
12 18
 }

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

@@ -2,20 +2,26 @@
2 2
 
3 3
 
4 4
 public class IntegerPrinter {
5
-
5
+       
6 6
     public String printIntegerAsBinary(int value){
7
-        return null;
7
+        String binary = Integer.toString(value,2);
8
+        System.out.println(binary);
9
+        return binary;
8 10
     }
9 11
 
10 12
     public String printIntegerAsOctal(int value){
11
-        return null;
13
+        String octal = Integer.toString(value,8);
14
+        System.out.println(octal);
15
+        return octal;
12 16
     }
13 17
 
14 18
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
19
+        String hex = Integer.toString(value,16);
20
+        System.out.println(hex);
21
+        return hex;
16 22
     }
17 23
 
18 24
     public static void main(String[] args){
19
-
25
+            
20 26
     }
21 27
 }

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

+ 6
- 2
LargestInteger.java View File

@@ -4,10 +4,14 @@
4 4
 public class LargestInteger {
5 5
 
6 6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
7
+        
8
+        int first = (integers[0] > integers[1]) ? integers[0] : integers[1];
9
+        int second = (first > integers[2]) ? first : integers[2];
10
+       
11
+        return second;
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

+ 4
- 2
NormalizeAngle.java View File

@@ -4,11 +4,13 @@
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        int normal = (angle%360);
8
+        return normal;
8 9
     }
9 10
 
10 11
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
12
+       int normal = Math.floorMod(integer,360);
13
+       return normal;
12 14
     }
13 15
 
14 16
     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=args
4
+comment1.target=void\ main(java.lang.String[])
5
+comment2.params=x\ y
6
+comment2.target=java.lang.Short\ add(int,\ int)
7
+comment3.params=x\ y
8
+comment3.target=java.lang.Short\ subtract(int,\ int)
9
+comment4.params=x\ y
10
+comment4.target=java.lang.Short\ multiply(int,\ int)
11
+comment5.params=x\ y
12
+comment5.target=java.lang.Short\ divide(int,\ int)
13
+comment6.params=x\ y
14
+comment6.target=java.lang.Short\ modulus(int,\ int)
15
+numComments=7

+ 41
- 1
ShortCalculator.java View File

@@ -1,5 +1,45 @@
1
- 
2 1
 
2
+import java.util.*;
3 3
 
4 4
 public class ShortCalculator {
5
+    public static void main(String[] args){
6
+        Scanner kb = new Scanner(System.in);
7
+        System.out.println("Please enter two numbers between 1 - 65525:");
8
+        int x = kb.nextInt();
9
+        int y = kb.nextInt();
10
+        ShortCalculator.add(x,y);
11
+        ShortCalculator.subtract(x,y);
12
+        ShortCalculator.multiply(x,y);
13
+        ShortCalculator.divide(x,y);
14
+        ShortCalculator.modulus(x,y);
15
+        
16
+
17
+    
18
+    }
19
+
20
+    public static Short add(int x, int y){
21
+        System.out.println("Your numbers sum: " + (short)(x+y));
22
+        return (short)(x+y);
23
+        
24
+    }
25
+
26
+    public static Short subtract(int x, int y){
27
+        System.out.println("Your numbers difference: " + (short)(x-y));
28
+        return (short)(x-y);
29
+    }
30
+
31
+    public static Short multiply(int x,int y){
32
+        System.out.println("Your numbers multiplied: "+ (short)(x*y));
33
+        return (short)(x*y);
34
+    } 
35
+
36
+    public static Short divide(int x,int y){
37
+        System.out.println("Your numbers divided: " + (short)(x/y));
38
+        return (short)(x/y);
39
+    }    
40
+
41
+    public static Short modulus(int x,int y){
42
+        System.out.println("Your numbers modulus is: " + (short)(x%y));
43
+        return (short)(x%y);
44
+    }
5 45
 }

BIN
ShortCalculatorTest.class View File


+ 5
- 0
ShortCalculatorTest.ctxt View File

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+numComments=2

+ 0
- 5
ShortCalculatorTest.java View File

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

+ 12
- 12
package.bluej View File

@@ -11,19 +11,19 @@ dependency3.type=UsesDependency
11 11
 dependency4.from=IntegerPrinterTest
12 12
 dependency4.to=IntegerPrinter
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
14
+editor.fx.0.height=714
15
+editor.fx.0.width=800
16
+editor.fx.0.x=518
17
+editor.fx.0.y=23
18
+objectbench.height=99
19
+objectbench.width=637
20
+package.divider.horizontal=0.5996275605214153
21
+package.divider.vertical=0.8384146341463414
22
+package.editor.height=543
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=2
25
+package.editor.y=25
26
+package.frame.height=714
27 27
 package.frame.width=1094
28 28
 package.numDependencies=4
29 29
 package.numTargets=10