rayskeez21 6 år sedan
förälder
incheckning
3474b69d30

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

+ 7
- 3
Factorial.java Visa fil

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

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

+ 8
- 4
IntegerPrinter.java Visa fil

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

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

+ 9
- 2
LargestInteger.java Visa fil

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

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

+ 3
- 2
NormalizeAngle.java Visa fil

@@ -4,11 +4,12 @@
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
+        
12
+        return Math.floorMod(integer,360);
12 13
     }
13 14
 
14 15
     public static void main(String[] args){

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


+ 13
- 0
ShortCalculator.ctxt Visa fil

@@ -0,0 +1,13 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=num1\ num2
4
+comment1.target=short\ sum(short,\ short)
5
+comment2.params=num1\ num2
6
+comment2.target=short\ diff(short,\ short)
7
+comment3.params=num1\ num2
8
+comment3.target=short\ prod(short,\ short)
9
+comment4.params=num1\ num2
10
+comment4.target=short\ quot(short,\ short)
11
+comment5.params=num1\ num2
12
+comment5.target=short\ remain(short,\ short)
13
+numComments=6

+ 33
- 0
ShortCalculator.java Visa fil

@@ -2,4 +2,37 @@
2 2
 
3 3
 
4 4
 public class ShortCalculator {
5
+    
6
+    public short sum(short num1, short num2){
7
+    
8
+    return (short)(num1 + num2);
9
+    
10
+    }
11
+    
12
+    public short diff(short num1,short num2){
13
+    
14
+    return (short)(num1 - num2);
15
+    
16
+    }
17
+    
18
+    public short prod(short num1, short num2){
19
+    
20
+    return (short)(num1 * num2);
21
+    
22
+    }
23
+    
24
+    public short quot(short num1, short num2){
25
+    
26
+    return (short)(num1 / num2);
27
+    
28
+    }
29
+    
30
+    public short remain(short num1, short num2){
31
+    
32
+    return (short)(num1 % num2);
33
+    
34
+    }
35
+    
36
+    
37
+    
5 38
 }

Binär
ShortCalculatorTest.class Visa fil


+ 15
- 0
ShortCalculatorTest.ctxt Visa fil

@@ -0,0 +1,15 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ shortVariableSumTest()
7
+comment3.params=
8
+comment3.target=void\ shortVariablediffTest()
9
+comment4.params=
10
+comment4.target=void\ shortVariableProdTest()
11
+comment5.params=
12
+comment5.target=void\ shortVariableQuotTest()
13
+comment6.params=
14
+comment6.target=void\ shortVariableRemainderTest()
15
+numComments=7

+ 65
- 1
ShortCalculatorTest.java Visa fil

@@ -1,5 +1,69 @@
1 1
  
2 2
 
3
-
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
4 6
 public class ShortCalculatorTest {
7
+    private ShortCalculator shortCalculator;
8
+    @Before
9
+    public void setUp(){
10
+      shortCalculator = new ShortCalculator();  
11
+    
12
+    }
13
+    @Test
14
+    public void shortVariableSumTest(){
15
+        //:Given
16
+        short expected = 30;
17
+
18
+        //:When
19
+        short actual = shortCalculator.sum((short)10,(short)20);
20
+
21
+        //:Then
22
+        Assert.assertEquals(expected, actual);
23
+    }
24
+    @Test
25
+    public void shortVariablediffTest(){
26
+        //:Given
27
+        short expected = 10;
28
+
29
+        //:When
30
+        short actual = shortCalculator.diff((short)20,(short)10);
31
+
32
+        //:Then
33
+        Assert.assertEquals(expected, actual);
34
+    }
35
+    @Test
36
+    public void shortVariableProdTest(){
37
+        //:Given
38
+        short expected = 200;
39
+
40
+        //:When
41
+        short actual = shortCalculator.prod((short)10,(short)20);
42
+
43
+        //:Then
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+    @Test
47
+    public void shortVariableQuotTest(){
48
+        //:Given
49
+        short expected = 2;
50
+
51
+        //:When
52
+        short actual = shortCalculator.quot((short)20,(short)10);
53
+
54
+        //:Then
55
+        Assert.assertEquals(expected, actual);
56
+    }
57
+    @Test
58
+    public void shortVariableRemainderTest(){
59
+        //:Given
60
+        short expected = 1;
61
+
62
+        //:When
63
+        short actual = shortCalculator.remain((short)10,(short)3);
64
+
65
+        //:Then
66
+        Assert.assertEquals(expected, actual);
67
+    }
5 68
 }
69
+

+ 6
- 6
package.bluej Visa fil

@@ -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=240
17
+editor.fx.0.y=24
18 18
 objectbench.height=101
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
19
+objectbench.width=608
20
+package.divider.horizontal=0.5726256983240223
21 21
 package.divider.vertical=0.837593984962406
22 22
 package.editor.height=550
23 23
 package.editor.width=968