Bladeren bron

Committing BasicComputations

Navya Sanal 6 jaren geleden
bovenliggende
commit
ec36aec45f

BIN
Factorial.class Bestand weergeven


+ 5
- 0
Factorial.ctxt Bestand weergeven

@@ -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
- 6
Factorial.java Bestand weergeven

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

BIN
FactorialTest.class Bestand weergeven


+ 7
- 0
FactorialTest.ctxt Bestand weergeven

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


+ 11
- 0
IntegerPrinter.ctxt Bestand weergeven

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

+ 21
- 6
IntegerPrinter.java Bestand weergeven

@@ -1,18 +1,33 @@
1
- 
2
-
3 1
 
2
+import java.lang.StringBuilder;
3
+import java.lang.*;
4
+//import java.lang.Integer.toOctalString();
5
+//import java.lang.Integer.toHexString();
4 6
 public class IntegerPrinter {
5 7
 
6 8
     public String printIntegerAsBinary(int value){
7
-        return null;
9
+        StringBuilder build = new StringBuilder();
10
+        while(value != 0)
11
+        {
12
+            build.insert(0,value % 2);
13
+
14
+            value = value / 2;
15
+        }
16
+        return build.toString();
8 17
     }
9 18
 
10
-    public String printIntegerAsOctal(int value){
11
-        return null;
19
+        public String printIntegerAsOctal(int value){
20
+            StringBuilder build = new StringBuilder();
21
+            String newString = Integer.toOctalString(value);
22
+            return newString;
23
+        
12 24
     }
13 25
 
14 26
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
27
+        StringBuilder build = new StringBuilder();
28
+        String newString = Integer.toHexString(value);
29
+        return newString;
30
+        
16 31
     }
17 32
 
18 33
     public static void main(String[] args){

BIN
IntegerPrinterTest.class Bestand weergeven


+ 11
- 0
IntegerPrinterTest.ctxt Bestand weergeven

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


+ 7
- 0
LargestInteger.ctxt Bestand weergeven

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

+ 21
- 4
LargestInteger.java Bestand weergeven

@@ -1,13 +1,30 @@
1
- 
2
-
3 1
 
2
+import java.lang.Math;
4 3
 public class LargestInteger {
5 4
 
6 5
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
6
+        for(int i = 0;i <= 2 ;i++)
7
+        {
8
+            if(integers[i] > integers [i+1] && integers[i] > integers[i+2])
9
+            {
10
+                return integers[i];
11
+            }
12
+            else if(integers[i+1] > integers[i] && integers[i+1] > integers[i+2])
13
+            {
14
+                return integers[i+1];
15
+            }
16
+            else
17
+            {
18
+                return integers[i+2];
19
+            }
20
+        }
21
+        return 0;
8 22
     }
9 23
 
10 24
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
25
+        int max = Math.max(integers[0],integers[1]);
26
+        int max1 = Math.max(max,integers[2]);
27
+        return max1;
12 28
     }
13 29
 }
30
+

BIN
LargestIntegerTest.class Bestand weergeven


+ 9
- 0
LargestIntegerTest.ctxt Bestand weergeven

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


+ 9
- 0
NormalizeAngle.ctxt Bestand weergeven

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

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


+ 9
- 0
NormalizeAngleTest.ctxt Bestand weergeven

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


+ 3
- 0
ShortCalculator.ctxt Bestand weergeven

@@ -0,0 +1,3 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+numComments=1

BIN
ShortCalculatorTest.class Bestand weergeven


+ 3
- 0
ShortCalculatorTest.ctxt Bestand weergeven

@@ -0,0 +1,3 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+numComments=1

+ 6
- 6
package.bluej Bestand weergeven

@@ -11,13 +11,13 @@ 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
14
+editor.fx.0.height=722
15
+editor.fx.0.width=800
16
+editor.fx.0.x=320
17
+editor.fx.0.y=56
18 18
 objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
19
+objectbench.width=637
20
+package.divider.horizontal=0.5996275605214153
21 21
 package.divider.vertical=0.837593984962406
22 22
 package.editor.height=550
23 23
 package.editor.width=968