Froilan Miranda 6 anni fa
commit
99b956a77c

BIN
.DS_Store Vedi File


+ 12
- 0
Factorial.java Vedi File

1
+ 
2
+
3
+
4
+import java.math.BigInteger;
5
+
6
+public class Factorial {
7
+
8
+    public BigInteger factorialOf(Integer value){
9
+        return null;
10
+    }
11
+
12
+}

+ 30
- 0
FactorialTest.java Vedi File

1
+ 
2
+
3
+
4
+import org.junit.Assert;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+import java.math.BigInteger;
9
+
10
+public class FactorialTest {
11
+
12
+    private Factorial factorial;
13
+
14
+    @Before
15
+    public void setUp(){
16
+        factorial = new Factorial();
17
+    }
18
+
19
+    @Test
20
+    public void factorialOfTest(){
21
+        //:Given
22
+        BigInteger expected = new BigInteger("24");
23
+
24
+        //:When
25
+        BigInteger actual = factorial.factorialOf(4);
26
+
27
+        //:Then
28
+        Assert.assertEquals("Values should be equal", expected, actual);
29
+    }
30
+}

+ 21
- 0
IntegerPrinter.java Vedi File

1
+ 
2
+
3
+
4
+public class IntegerPrinter {
5
+
6
+    public String printIntegerAsBinary(int value){
7
+        return null;
8
+    }
9
+
10
+    public String printIntegerAsOctal(int value){
11
+        return null;
12
+    }
13
+
14
+    public String printIntegerAsHexadecimal(int value){
15
+        return null;
16
+    }
17
+
18
+    public static void main(String[] args){
19
+
20
+    }
21
+}

+ 53
- 0
IntegerPrinterTest.java Vedi File

1
+ 
2
+
3
+
4
+import org.junit.Assert;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+public class IntegerPrinterTest {
9
+
10
+    IntegerPrinter integerPrinter;
11
+
12
+    @Before
13
+    public void setUp(){
14
+        integerPrinter = new IntegerPrinter();
15
+    }
16
+
17
+    @Test
18
+    public void printIntegerAsBinaryTest(){
19
+        //:Given
20
+        String expected = "111110100";
21
+
22
+        //:When
23
+        String actual = integerPrinter.printIntegerAsBinary(500);
24
+
25
+        //:Then
26
+        Assert.assertEquals("The value equals 111110100", expected, actual);
27
+    }
28
+
29
+    @Test
30
+    public void printIntegerAsHexadecimal(){
31
+        //:Given
32
+        String expected = "1f4";
33
+
34
+        //:When
35
+        String actual = integerPrinter.printIntegerAsHexadecimal(500);
36
+
37
+        //:Then
38
+        Assert.assertEquals("The value equals 1f4", expected, actual);
39
+    }
40
+
41
+    @Test
42
+    public void printIntegerAsOctalTest(){
43
+        //:Given
44
+        String expected = "764";
45
+
46
+        //:When
47
+        String actual = integerPrinter.printIntegerAsOctal(500);
48
+
49
+        //:Then
50
+        Assert.assertEquals("The value equals 764", expected, actual);
51
+    }
52
+
53
+}

+ 13
- 0
LargestInteger.java Vedi File

1
+ 
2
+
3
+
4
+public class LargestInteger {
5
+
6
+    public Integer findLargestNumberUsingConditional(Integer[] integers){
7
+        return null;
8
+    }
9
+
10
+    public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
+        return null;
12
+    }
13
+}

+ 40
- 0
LargestIntegerTest.java Vedi File

1
+ 
2
+
3
+
4
+import org.junit.Assert;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+public class LargestIntegerTest {
9
+
10
+    private LargestInteger largestInteger;
11
+
12
+    @Before
13
+    public void setUp(){
14
+        largestInteger = new LargestInteger();
15
+    }
16
+
17
+    @Test
18
+    public void findLargestNumberUsingConditionalTest(){
19
+        // :Given
20
+        Integer expected = 30;
21
+
22
+        // :When
23
+        Integer actual = largestInteger.findLargestNumberUsingConditional(new Integer[]{30,20,10});
24
+
25
+        // :Then
26
+        Assert.assertEquals("The Largest Number should be 30", expected, actual);
27
+    }
28
+
29
+    @Test
30
+    public void findLargestNumberUsingMathMaxTest(){
31
+        // :Given
32
+        Integer expected = 600;
33
+
34
+        // :When
35
+        Integer actual = largestInteger.findLargestNumberUsingMathMax(new Integer[]{300,200,600});
36
+
37
+        // :Then
38
+        Assert.assertEquals("The Largest Number should be 600.", expected, actual);
39
+    }
40
+}

+ 17
- 0
NormalizeAngle.java Vedi File

1
+ 
2
+
3
+
4
+public class NormalizeAngle {
5
+
6
+    public Integer normalizeValueUsingModulo(Integer angle){
7
+        return 0;
8
+    }
9
+
10
+    public Integer normalizeValueUsingFloorMod(Integer integer){
11
+        return 0;
12
+    }
13
+
14
+    public static void main(String[] args){
15
+
16
+    }
17
+}

+ 40
- 0
NormalizeAngleTest.java Vedi File

1
+ 
2
+
3
+
4
+import org.junit.Assert;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+public class NormalizeAngleTest {
9
+
10
+    private NormalizeAngle normalizeAngle;
11
+
12
+    @Before
13
+    public void setUp(){
14
+        normalizeAngle = new NormalizeAngle();
15
+    }
16
+
17
+    @Test
18
+    public void normalizeValueUsingModuloTest(){
19
+        //:Given
20
+        Integer expected = 60;
21
+
22
+        //:When
23
+        Integer actual = normalizeAngle.normalizeValueUsingModulo(780);
24
+
25
+        //:Then
26
+        Assert.assertEquals("The value equals 60", expected, actual);
27
+    }
28
+
29
+    @Test
30
+    public void normalizeValueUsingFloorModTest(){
31
+        //:Given
32
+        Integer expected = 60;
33
+
34
+        //:When
35
+        Integer actual = normalizeAngle.normalizeValueUsingFloorMod(780);
36
+
37
+        //:Then
38
+        Assert.assertEquals("The value equals 60", expected, actual);
39
+    }
40
+}

+ 25
- 0
README.md Vedi File

1
+# Integer Printer
2
+
3
+* Write a program that reads an integer and prints it in :
4
+1. binary
5
+2. Octal
6
+3. Hexadecimal
7
+
8
+
9
+# Normalize Angle
10
+* Write a program that reads an integer angle (which may be positive or negative) and normalizes it to a value between 0 and 359 degrees. Try it first with the % operator, then with floorMod.
11
+
12
+
13
+# Largest Integer
14
+
15
+* Using only the conditional operator, write a program that reads three integers and prints the largest. Repeat with Math.max
16
+
17
+
18
+# Factorial
19
+
20
+* Write a program that computes the factorial n! = 1 x 2 x ... x n, using BigInteger. Compute the factorial of 1000.
21
+
22
+
23
+# ShortValues
24
+
25
+* Write a program that reads in two numbers between 0 and 65535, stores them in short variables, and computes their unsigned sum, difference, product, quotient, and remainder , without converting them to int.

+ 5
- 0
ShortCalculator.java Vedi File

1
+ 
2
+
3
+
4
+public class ShortCalculator {
5
+}

+ 5
- 0
ShortCalculatorTest.java Vedi File

1
+ 
2
+
3
+
4
+public class ShortCalculatorTest {
5
+}

+ 107
- 0
package.bluej Vedi File

1
+#BlueJ package file
2
+dependency1.from=LargestIntegerTest
3
+dependency1.to=LargestInteger
4
+dependency1.type=UsesDependency
5
+dependency2.from=NormalizeAngleTest
6
+dependency2.to=NormalizeAngle
7
+dependency2.type=UsesDependency
8
+dependency3.from=FactorialTest
9
+dependency3.to=Factorial
10
+dependency3.type=UsesDependency
11
+dependency4.from=IntegerPrinterTest
12
+dependency4.to=IntegerPrinter
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
18
+objectbench.height=101
19
+objectbench.width=1070
20
+package.divider.horizontal=0.6
21
+package.divider.vertical=0.837593984962406
22
+package.editor.height=550
23
+package.editor.width=968
24
+package.editor.x=59
25
+package.editor.y=82
26
+package.frame.height=723
27
+package.frame.width=1094
28
+package.numDependencies=4
29
+package.numTargets=10
30
+package.showExtends=true
31
+package.showUses=true
32
+project.charset=UTF-8
33
+readme.height=58
34
+readme.name=@README
35
+readme.width=47
36
+readme.x=10
37
+readme.y=10
38
+target1.height=50
39
+target1.name=Factorial
40
+target1.showInterface=false
41
+target1.type=ClassTarget
42
+target1.width=80
43
+target1.x=160
44
+target1.y=10
45
+target10.height=50
46
+target10.name=IntegerPrinterTest
47
+target10.showInterface=false
48
+target10.type=UnitTestTargetJunit4
49
+target10.width=140
50
+target10.x=10
51
+target10.y=370
52
+target2.height=50
53
+target2.name=NormalizeAngle
54
+target2.showInterface=false
55
+target2.type=ClassTarget
56
+target2.width=120
57
+target2.x=70
58
+target2.y=70
59
+target3.height=50
60
+target3.name=IntegerPrinter
61
+target3.showInterface=false
62
+target3.type=ClassTarget
63
+target3.width=110
64
+target3.x=10
65
+target3.y=130
66
+target4.height=50
67
+target4.name=ShortCalculator
68
+target4.showInterface=false
69
+target4.type=ClassTarget
70
+target4.width=120
71
+target4.x=130
72
+target4.y=130
73
+target5.height=50
74
+target5.name=LargestInteger
75
+target5.showInterface=false
76
+target5.type=ClassTarget
77
+target5.width=120
78
+target5.x=10
79
+target5.y=190
80
+target6.height=50
81
+target6.name=LargestIntegerTest
82
+target6.showInterface=false
83
+target6.type=UnitTestTargetJunit4
84
+target6.width=140
85
+target6.x=250
86
+target6.y=190
87
+target7.height=50
88
+target7.name=ShortCalculatorTest
89
+target7.showInterface=false
90
+target7.type=ClassTarget
91
+target7.width=150
92
+target7.x=10
93
+target7.y=250
94
+target8.height=50
95
+target8.name=NormalizeAngleTest
96
+target8.showInterface=false
97
+target8.type=UnitTestTargetJunit4
98
+target8.width=150
99
+target8.x=10
100
+target8.y=310
101
+target9.height=50
102
+target9.name=FactorialTest
103
+target9.showInterface=false
104
+target9.type=UnitTestTargetJunit4
105
+target9.width=110
106
+target9.x=410
107
+target9.y=260