Ben Blinebury 6 gadus atpakaļ
vecāks
revīzija
6a881db26f

Binārs
Factorial.class Parādīt failu


+ 5
- 0
Factorial.ctxt Parādīt failu

@@ -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
- 1
Factorial.java Parādīt failu

@@ -6,7 +6,13 @@ import java.math.BigInteger;
6 6
 public class Factorial {
7 7
 
8 8
     public BigInteger factorialOf(Integer value){
9
-        return null;
9
+        long big = 1;
10
+        
11
+        for (long i = 1; i <= value; i++)
12
+            
13
+            big *= i;
14
+        
15
+        return BigInteger.valueOf(big);
10 16
     }
11 17
 
12 18
 }

Binārs
FactorialTest.class Parādīt failu


+ 7
- 0
FactorialTest.ctxt Parādīt failu

@@ -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ārs
IntegerPrinter.class Parādīt failu


+ 11
- 0
IntegerPrinter.ctxt Parādīt failu

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

+ 10
- 4
IntegerPrinter.java Parādīt failu

@@ -4,18 +4,24 @@
4 4
 public class IntegerPrinter {
5 5
 
6 6
     public String printIntegerAsBinary(int value){
7
-        return null;
7
+        String b = Integer.toString(value, 2);
8
+        System.out.print(b);
9
+        return b;
8 10
     }
9 11
 
10 12
     public String printIntegerAsOctal(int value){
11
-        return null;
13
+        String o = Integer.toString(value, 8);
14
+        System.out.print(o);
15
+        return o;
12 16
     }
13 17
 
14 18
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
19
+        String h = Integer.toString(value, 16);
20
+        System.out.print(h);
21
+        return h;
16 22
     }
17 23
 
18 24
     public static void main(String[] args){
19
-
25
+      
20 26
     }
21 27
 }

Binārs
IntegerPrinterTest.class Parādīt failu


+ 11
- 0
IntegerPrinterTest.ctxt Parādīt failu

@@ -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ārs
LargestInteger.class Parādīt failu


+ 7
- 0
LargestInteger.ctxt Parādīt failu

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

+ 7
- 2
LargestInteger.java Parādīt failu

@@ -4,10 +4,15 @@
4 4
 public class LargestInteger {
5 5
 
6 6
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
7
+        int large = (integers[1] > integers[2]) ? integers[1] : integers[2];
8
+        int win = (large > integers[0]) ? large : integers [0];
9
+        System.out.println(win);
10
+        return win;
8 11
     }
9 12
 
10 13
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
14
+        int winner = Math.max(integers[0],(Math.max(integers[1],integers[2])));
15
+        System.out.print(winner);
16
+        return winner;
12 17
     }
13 18
 }

Binārs
LargestIntegerTest.class Parādīt failu


+ 9
- 0
LargestIntegerTest.ctxt Parādīt failu

@@ -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ārs
NormalizeAngle.class Parādīt failu


+ 9
- 0
NormalizeAngle.ctxt Parādīt failu

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

+ 6
- 2
NormalizeAngle.java Parādīt failu

@@ -4,11 +4,15 @@
4 4
 public class NormalizeAngle {
5 5
 
6 6
     public Integer normalizeValueUsingModulo(Integer angle){
7
-        return 0;
7
+        int norm = angle % 360;
8
+        
9
+        return norm;
8 10
     }
9 11
 
10 12
     public Integer normalizeValueUsingFloorMod(Integer integer){
11
-        return 0;
13
+        int norm = Math.floorMod(integer, 360);
14
+        
15
+        return norm;
12 16
     }
13 17
 
14 18
     public static void main(String[] args){

Binārs
NormalizeAngleTest.class Parādīt failu


+ 9
- 0
NormalizeAngleTest.ctxt Parādīt failu

@@ -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ārs
ShortCalculator.class Parādīt failu


+ 15
- 0
ShortCalculator.ctxt Parādīt failu

@@ -0,0 +1,15 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+comment2.params=x\ y
6
+comment2.target=java.lang.Short\ sum(int,\ int)
7
+comment3.params=x\ y
8
+comment3.target=java.lang.Short\ difference(int,\ int)
9
+comment4.params=x\ y
10
+comment4.target=java.lang.Short\ product(int,\ int)
11
+comment5.params=x\ y
12
+comment5.target=java.lang.Short\ quotient(int,\ int)
13
+comment6.params=x\ y
14
+comment6.target=java.lang.Short\ remainder(int,\ int)
15
+numComments=7

+ 37
- 1
ShortCalculator.java Parādīt failu

@@ -1,5 +1,41 @@
1
- 
2 1
 
2
+import java.util.*;
3 3
 
4 4
 public class ShortCalculator {
5
+
6
+    public static void main(String[] args) {
7
+        Scanner input = new Scanner(System.in);
8
+        System.out.println("Please insert your first number.");
9
+        int x = input.nextInt();
10
+        System.out.println("Please insert your second number.");
11
+        
12
+        int y = input.nextInt();
13
+        
14
+        System.out.println("Adding them equals " + ShortCalculator.sum(x, y));
15
+        System.out.println("Subtracting them equals " + ShortCalculator.difference(x,y));
16
+        System.out.println("Multiplying them equals " + ShortCalculator.product(x,y));
17
+        System.out.println("Dividing them equals " + ShortCalculator.quotient(x, y));
18
+        System.out.println("The remainder between them is " + ShortCalculator.remainder(x,y));
19
+    }
20
+
21
+    public static Short sum(int x, int y){
22
+        return (short)(x + y);
23
+    }
24
+
25
+    public static Short difference(int x, int y) {
26
+        return (short)(x - y);
27
+    }
28
+
29
+    public static Short product(int x, int y) {
30
+        return (short)(x * y);   
31
+    }
32
+
33
+    public static Short quotient(int x, int y) {
34
+        return (short)(x / y);   
35
+    }
36
+
37
+    public static Short remainder(int x, int y) {
38
+        return (short)(x % y);   
39
+    }
40
+
5 41
 }

Binārs
ShortCalculatorTest.class Parādīt failu


+ 3
- 0
ShortCalculatorTest.ctxt Parādīt failu

@@ -0,0 +1,3 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+numComments=1