Browse Source

updated commit

Joshua Chung 6 years ago
parent
commit
14d5bd4260

BIN
Factorial.class View File


+ 5
- 0
Factorial.ctxt View File

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
 
5
 
6
 public class Factorial {
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

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
 import org.junit.Assert;
4
 import org.junit.Assert;
5
 import org.junit.Before;
5
 import org.junit.Before;
6
 import org.junit.Test;
6
 import org.junit.Test;
7
-
8
 import java.math.BigInteger;
7
 import java.math.BigInteger;
9
 
8
 
10
 public class FactorialTest {
9
 public class FactorialTest {

BIN
IntegerPrinter.class View File


+ 11
- 0
IntegerPrinter.ctxt View File

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
 
3
 
4
 public class IntegerPrinter {
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
     public String printIntegerAsOctal(int value){
10
     public String printIntegerAsOctal(int value){
11
-        return null;
11
+        return Integer.toOctalString(value);
12
     }
12
     }
13
 
13
 
14
     public String printIntegerAsHexadecimal(int value){
14
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
15
+        return Integer.toHexString(value);
16
     }
16
     }
17
 
17
 
18
     public static void main(String[] args){
18
     public static void main(String[] args){

BIN
IntegerPrinterTest.class View File


+ 11
- 0
IntegerPrinterTest.ctxt View File

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

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
- 
1
+import java.lang.Math;
2
+import java.util.Arrays;
2
 
3
 
3
 
4
 
4
 public class LargestInteger {
5
 public class LargestInteger {
5
 
6
 
6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
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
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
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

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
- 
2
-
3
-
4
 import org.junit.Assert;
1
 import org.junit.Assert;
5
 import org.junit.Before;
2
 import org.junit.Before;
6
 import org.junit.Test;
3
 import org.junit.Test;

BIN
NormalizeAngle.class View File


+ 9
- 0
NormalizeAngle.ctxt View File

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

BIN
NormalizeAngleTest.class View File


+ 9
- 0
NormalizeAngleTest.ctxt View File

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

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
 
2
 
3
 
3
 
4
 public class ShortCalculator {
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
- 
2
-
3
-
4
-public class ShortCalculatorTest {
5
-}