Khalil Saboor 6 år sedan
förälder
incheckning
3026d943df

Binär
Factorial.class Visa fil


+ 5
- 0
Factorial.ctxt Visa fil

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

+ 8
- 2
Factorial.java Visa fil

@@ -1,12 +1,18 @@
1 1
  
2 2
 
3
-
3
+import java.util.*;
4 4
 import java.math.BigInteger;
5 5
 
6 6
 public class Factorial {
7 7
 
8 8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+        BigInteger factorial = BigInteger.ONE;
10
+        int number = 1;
11
+        for (int i = value; i > 0; i--) {
12
+            factorial = factorial.multiply(BigInteger.valueOf(i));
13
+        }
14
+
15
+        return factorial;
10 16
     }
11 17
 
12 18
 }

Binär
FactorialTest.class Visa fil


+ 7
- 0
FactorialTest.ctxt Visa fil

@@ -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är
IntegerPrinter.class Visa fil


+ 11
- 0
IntegerPrinter.ctxt Visa fil

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

+ 20
- 8
IntegerPrinter.java Visa fil

@@ -1,21 +1,33 @@
1
- 
1
+ import java.util.Scanner;
2 2
 
3 3
 
4 4
 public class IntegerPrinter {
5 5
 
6
-    public String printIntegerAsBinary(int value){
7
-        return null;
6
+    public static String printIntegerAsBinary(int value){
7
+        String binary = Integer.toBinaryString(value);
8
+        return binary;
8 9
     }
9 10
 
10
-    public String printIntegerAsOctal(int value){
11
-        return null;
11
+    public static String printIntegerAsOctal(int value){
12
+        String octal = Integer.toOctalString(value);
13
+        return octal;
14
+        //return octal;
12 15
     }
13 16
 
14
-    public String printIntegerAsHexadecimal(int value){
15
-        return null;
17
+    public static String printIntegerAsHexadecimal(int value){
18
+        String Hexdecimal = Integer.toHexString(value);
19
+        return Hexdecimal;
16 20
     }
17 21
 
18 22
     public static void main(String[] args){
19
-
23
+        Scanner in = new Scanner(System.in);
24
+        System.out.println("Please enter an interger");
25
+        int i = in.nextInt();
26
+        
27
+        printIntegerAsBinary(i);
28
+        printIntegerAsHexadecimal(i);
29
+        printIntegerAsHexadecimal(i);
30
+        
31
+        
20 32
     }
21 33
 }

Binär
IntegerPrinterTest.class Visa fil


+ 11
- 0
IntegerPrinterTest.ctxt Visa fil

@@ -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är
LargestInteger.class Visa fil


+ 7
- 0
LargestInteger.ctxt Visa fil

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

+ 11
- 1
LargestInteger.java Visa fil

@@ -4,10 +4,20 @@
4 4
 public class LargestInteger {
5 5
 
6 6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
+        int i = 0;
8
+        int max = 0;
9
+        for(i = 0; i <integers.length ; i++){
10
+            if(){
11
+                
12
+            }
13
+        }
7 14
         return null;
8 15
     }
9 16
 
17
+     
10 18
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
19
+        
20
+        return Math.max(integers[0],Math.max(integers[1],integers[2]));
21
+    
12 22
     }
13 23
 }

Binär
LargestIntegerTest.class Visa fil


+ 9
- 0
LargestIntegerTest.ctxt Visa fil

@@ -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är
NormalizeAngle.class Visa fil


+ 9
- 0
NormalizeAngle.ctxt Visa fil

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

+ 1
- 1
NormalizeAngle.java Visa fil

@@ -4,7 +4,7 @@
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        return angle%60;
8 8
     }
9 9
 
10 10
     public Integer normalizeValueUsingFloorMod(Integer integer){

Binär
NormalizeAngleTest.class Visa fil


+ 9
- 0
NormalizeAngleTest.ctxt Visa fil

@@ -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är
ShortCalculator.class Visa fil


+ 5
- 0
ShortCalculator.ctxt Visa fil

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=a\ b
4
+comment1.target=short\ add(short,\ short)
5
+numComments=2

+ 4
- 0
ShortCalculator.java Visa fil

@@ -2,4 +2,8 @@
2 2
 
3 3
 
4 4
 public class ShortCalculator {
5
+ 
6
+    public static short add(short a,short b) {  
7
+            return (short)(a + b);
8
+        }
5 9
 }

Binär
ShortCalculatorTest.class Visa fil


+ 5
- 0
ShortCalculatorTest.ctxt Visa fil

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+comment1.params=
4
+comment1.target=void\ CalculatorTest()
5
+numComments=2

+ 15
- 1
ShortCalculatorTest.java Visa fil

@@ -1,5 +1,19 @@
1
- 
1
+import org.junit.Assert;
2
+import org.junit.Before;
3
+import org.junit.Test; 
2 4
 
3 5
 
4 6
 public class ShortCalculatorTest {
7
+    @Test
8
+    public void CalculatorTest()
9
+    {             
10
+        short a = 1;
11
+        short b = 2;
12
+        short expected = 3;
13
+        short actual = ShortCalculator.add(a,b);
14
+        
15
+        
16
+        
17
+        Assert.assertEquals(expected,actual);
18
+    }
5 19
 }

+ 32
- 29
package.bluej Visa fil

@@ -11,21 +11,24 @@ 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
+dependency5.from=ShortCalculatorTest
15
+dependency5.to=ShortCalculator
16
+dependency5.type=UsesDependency
17
+editor.fx.0.height=709
18
+editor.fx.0.width=800
19
+editor.fx.0.x=-40
20
+editor.fx.0.y=23
18 21
 objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
22
+objectbench.width=637
23
+package.divider.horizontal=0.5996275605214153
24
+package.divider.vertical=0.8341013824884793
25
+package.editor.height=536
23 26
 package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
27
+package.editor.x=76
28
+package.editor.y=136
29
+package.frame.height=709
27 30
 package.frame.width=1094
28
-package.numDependencies=4
31
+package.numDependencies=5
29 32
 package.numTargets=10
30 33
 package.showExtends=true
31 34
 package.showUses=true
@@ -40,15 +43,15 @@ target1.name=Factorial
40 43
 target1.showInterface=false
41 44
 target1.type=ClassTarget
42 45
 target1.width=80
43
-target1.x=160
44
-target1.y=10
46
+target1.x=410
47
+target1.y=100
45 48
 target10.height=50
46 49
 target10.name=IntegerPrinterTest
47 50
 target10.showInterface=false
48 51
 target10.type=UnitTestTargetJunit4
49 52
 target10.width=140
50
-target10.x=10
51
-target10.y=370
53
+target10.x=800
54
+target10.y=240
52 55
 target2.height=50
53 56
 target2.name=NormalizeAngle
54 57
 target2.showInterface=false
@@ -61,36 +64,36 @@ target3.name=IntegerPrinter
61 64
 target3.showInterface=false
62 65
 target3.type=ClassTarget
63 66
 target3.width=110
64
-target3.x=10
65
-target3.y=130
67
+target3.x=840
68
+target3.y=340
66 69
 target4.height=50
67 70
 target4.name=ShortCalculator
68 71
 target4.showInterface=false
69 72
 target4.type=ClassTarget
70 73
 target4.width=120
71
-target4.x=130
72
-target4.y=130
74
+target4.x=770
75
+target4.y=140
73 76
 target5.height=50
74 77
 target5.name=LargestInteger
75 78
 target5.showInterface=false
76 79
 target5.type=ClassTarget
77 80
 target5.width=120
78
-target5.x=10
79
-target5.y=190
81
+target5.x=250
82
+target5.y=300
80 83
 target6.height=50
81 84
 target6.name=LargestIntegerTest
82 85
 target6.showInterface=false
83 86
 target6.type=UnitTestTargetJunit4
84 87
 target6.width=140
85
-target6.x=250
86
-target6.y=190
88
+target6.x=180
89
+target6.y=180
87 90
 target7.height=50
88 91
 target7.name=ShortCalculatorTest
89 92
 target7.showInterface=false
90
-target7.type=ClassTarget
93
+target7.type=UnitTestTargetJunit4
91 94
 target7.width=150
92
-target7.x=10
93
-target7.y=250
95
+target7.x=770
96
+target7.y=40
94 97
 target8.height=50
95 98
 target8.name=NormalizeAngleTest
96 99
 target8.showInterface=false
@@ -103,5 +106,5 @@ target9.name=FactorialTest
103 106
 target9.showInterface=false
104 107
 target9.type=UnitTestTargetJunit4
105 108
 target9.width=110
106
-target9.x=410
107
-target9.y=260
109
+target9.x=470
110
+target9.y=170