Procházet zdrojové kódy

finsihed assisngment

Chad před 6 roky
rodič
revize
ad15a34cac

binární
Factorial.class Zobrazit soubor


+ 5
- 0
Factorial.ctxt Zobrazit soubor

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
- 2
Factorial.java Zobrazit soubor

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

binární
FactorialTest.class Zobrazit soubor


+ 7
- 0
FactorialTest.ctxt Zobrazit soubor

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ární
IntegerPrinter.class Zobrazit soubor


+ 11
- 0
IntegerPrinter.ctxt Zobrazit soubor

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
- 3
IntegerPrinter.java Zobrazit soubor

4
 public class IntegerPrinter {
4
 public class IntegerPrinter {
5
 
5
 
6
     public String printIntegerAsBinary(int value){
6
     public String printIntegerAsBinary(int value){
7
-        return null;
7
+    
8
+        return (Integer.toBinaryString(value));
8
     }
9
     }
9
 
10
 
10
     public String printIntegerAsOctal(int value){
11
     public String printIntegerAsOctal(int value){
11
-        return null;
12
+        return (Integer.toOctalString(value));
12
     }
13
     }
13
 
14
 
14
     public String printIntegerAsHexadecimal(int value){
15
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
16
+        return (Integer.toHexString(value));
16
     }
17
     }
17
 
18
 
18
     public static void main(String[] args){
19
     public static void main(String[] args){

binární
IntegerPrinterTest.class Zobrazit soubor


+ 11
- 0
IntegerPrinterTest.ctxt Zobrazit soubor

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ární
LargestInteger.class Zobrazit soubor


+ 7
- 0
LargestInteger.ctxt Zobrazit soubor

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

+ 17
- 2
LargestInteger.java Zobrazit soubor

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

binární
LargestIntegerTest.class Zobrazit soubor


+ 9
- 0
LargestIntegerTest.ctxt Zobrazit soubor

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ární
NormalizeAngle.class Zobrazit soubor


+ 9
- 0
NormalizeAngle.ctxt Zobrazit soubor

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

+ 7
- 2
NormalizeAngle.java Zobrazit soubor

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 = (angle % 360);
8
+        
9
+        return angle;
8
     }
10
     }
9
 
11
 
10
     public Integer normalizeValueUsingFloorMod(Integer integer){
12
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
13
+        
14
+        integer = Math.floorMod(integer, 360);
15
+        
16
+        return integer;
12
     }
17
     }
13
 
18
 
14
     public static void main(String[] args){
19
     public static void main(String[] args){

binární
NormalizeAngleTest.class Zobrazit soubor


+ 9
- 0
NormalizeAngleTest.ctxt Zobrazit soubor

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ární
ShortCalculator.class Zobrazit soubor


+ 5
- 0
ShortCalculator.ctxt Zobrazit soubor

1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=num1\ num2
4
+comment1.target=java.lang.Short[]\ shortValues(short,\ short)
5
+numComments=2

+ 12
- 0
ShortCalculator.java Zobrazit soubor

2
 
2
 
3
 
3
 
4
 public class ShortCalculator {
4
 public class ShortCalculator {
5
+    
6
+        public Short[] shortValues(short num1, short num2){
7
+    
8
+    short sum = (short)(num1+num2);
9
+    short difference = (short)(num1 - num2);
10
+    short product = (short)(num1 * num2);
11
+    short quotient = (short)(num1 / num2);
12
+    short remainder = (short)(num1 % num2);
13
+    Short[] x = {sum, difference, product, quotient, remainder};
14
+    return x;
15
+    
16
+    }
5
 }
17
 }

binární
ShortCalculatorTest.class Zobrazit soubor


+ 7
- 0
ShortCalculatorTest.ctxt Zobrazit soubor

1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+comment1.params=
4
+comment1.target=void\ setUp()
5
+comment2.params=
6
+comment2.target=void\ shortValuesTest()
7
+numComments=3

+ 24
- 1
ShortCalculatorTest.java Zobrazit soubor

1
  
1
  
2
-
2
+import org.junit.Assert;
3
+import org.junit.Before;
4
+import org.junit.Test;
3
 
5
 
4
 public class ShortCalculatorTest {
6
 public class ShortCalculatorTest {
7
+    
8
+    private ShortCalculator ShortCalc;
9
+    @Before
10
+    public void setUp(){
11
+        ShortCalc = new ShortCalculator();
12
+    }
13
+    
14
+    @Test
15
+    public void shortValuesTest(){
16
+        // :Given
17
+        Short[] expected = {6, 2, 8, 2, 0};
18
+        short testnum = 4;
19
+        short testnum2 = 2;
20
+
21
+        // :When
22
+        Short[] actual = ShortCalc.shortValues(testnum, testnum2);
23
+
24
+        // :Then
25
+        Assert.assertEquals(expected, actual);
26
+    }
27
+    
5
 }
28
 }

+ 14
- 11
package.bluej Zobrazit soubor

11
 dependency4.from=IntegerPrinterTest
11
 dependency4.from=IntegerPrinterTest
12
 dependency4.to=IntegerPrinter
12
 dependency4.to=IntegerPrinter
13
 dependency4.type=UsesDependency
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=722
18
+editor.fx.0.width=800
19
+editor.fx.0.x=407
20
+editor.fx.0.y=78
18
 objectbench.height=101
21
 objectbench.height=101
19
 objectbench.width=1070
22
 objectbench.width=1070
20
 package.divider.horizontal=0.6
23
 package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
24
+package.divider.vertical=0.8373493975903614
25
+package.editor.height=549
23
 package.editor.width=968
26
 package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
27
+package.editor.x=308
28
+package.editor.y=33
29
+package.frame.height=722
27
 package.frame.width=1094
30
 package.frame.width=1094
28
-package.numDependencies=4
31
+package.numDependencies=5
29
 package.numTargets=10
32
 package.numTargets=10
30
 package.showExtends=true
33
 package.showExtends=true
31
 package.showUses=true
34
 package.showUses=true
87
 target7.height=50
90
 target7.height=50
88
 target7.name=ShortCalculatorTest
91
 target7.name=ShortCalculatorTest
89
 target7.showInterface=false
92
 target7.showInterface=false
90
-target7.type=ClassTarget
93
+target7.type=UnitTestTargetJunit4
91
 target7.width=150
94
 target7.width=150
92
 target7.x=10
95
 target7.x=10
93
 target7.y=250
96
 target7.y=250