瀏覽代碼

finsihed assisngment

Chad 6 年之前
父節點
當前提交
ad15a34cac

二進制
Factorial.class 查看文件


+ 5
- 0
Factorial.ctxt 查看文件

@@ -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
- 2
Factorial.java 查看文件

@@ -1,12 +1,17 @@
1 1
  
2 2
 
3
-
3
+import java.util.Scanner;
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 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
 }

二進制
FactorialTest.class 查看文件


+ 7
- 0
FactorialTest.ctxt 查看文件

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

二進制
IntegerPrinter.class 查看文件


+ 11
- 0
IntegerPrinter.ctxt 查看文件

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

+ 4
- 3
IntegerPrinter.java 查看文件

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

二進制
IntegerPrinterTest.class 查看文件


+ 11
- 0
IntegerPrinterTest.ctxt 查看文件

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

二進制
LargestInteger.class 查看文件


+ 7
- 0
LargestInteger.ctxt 查看文件

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

+ 17
- 2
LargestInteger.java 查看文件

@@ -4,10 +4,25 @@
4 4
 public class LargestInteger {
5 5
 
6 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 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
 }

二進制
LargestIntegerTest.class 查看文件


+ 9
- 0
LargestIntegerTest.ctxt 查看文件

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

二進制
NormalizeAngle.class 查看文件


+ 9
- 0
NormalizeAngle.ctxt 查看文件

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

+ 7
- 2
NormalizeAngle.java 查看文件

@@ -4,11 +4,16 @@
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        angle = (angle % 360);
8
+        
9
+        return angle;
8 10
     }
9 11
 
10 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 19
     public static void main(String[] args){

二進制
NormalizeAngleTest.class 查看文件


+ 9
- 0
NormalizeAngleTest.ctxt 查看文件

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

二進制
ShortCalculator.class 查看文件


+ 5
- 0
ShortCalculator.ctxt 查看文件

@@ -0,0 +1,5 @@
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 查看文件

@@ -2,4 +2,16 @@
2 2
 
3 3
 
4 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
 }

二進制
ShortCalculatorTest.class 查看文件


+ 7
- 0
ShortCalculatorTest.ctxt 查看文件

@@ -0,0 +1,7 @@
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 查看文件

@@ -1,5 +1,28 @@
1 1
  
2
-
2
+import org.junit.Assert;
3
+import org.junit.Before;
4
+import org.junit.Test;
3 5
 
4 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 查看文件

@@ -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=722
18
+editor.fx.0.width=800
19
+editor.fx.0.x=407
20
+editor.fx.0.y=78
18 21
 objectbench.height=101
19 22
 objectbench.width=1070
20 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 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 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
@@ -87,7 +90,7 @@ target6.y=190
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 95
 target7.x=10
93 96
 target7.y=250