Tommy Rogers vor 6 Jahren
Ursprung
Commit
89ae0ed7fc

BIN
Factorial.class Datei anzeigen


+ 5
- 0
Factorial.ctxt Datei anzeigen

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

+ 6
- 1
Factorial.java Datei anzeigen

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

BIN
FactorialTest.class Datei anzeigen


+ 7
- 0
FactorialTest.ctxt Datei anzeigen

@@ -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
IntegerPrinter.class Datei anzeigen


+ 11
- 0
IntegerPrinter.ctxt Datei anzeigen

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

+ 6
- 4
IntegerPrinter.java Datei anzeigen

@@ -1,18 +1,20 @@
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.toString(value, 2));
7
+        return Integer.toString(value, 2);
8 8
     }
9 9
 
10 10
     public String printIntegerAsOctal(int value){
11
-        return null;
11
+        System.out.println(Integer.toString(value, 8));
12
+        return Integer.toString(value, 8);
12 13
     }
13 14
 
14 15
     public String printIntegerAsHexadecimal(int value){
15
-        return null;
16
+        System.out.println(Integer.toString(value, 16));
17
+        return Integer.toString(value, 16);
16 18
     }
17 19
 
18 20
     public static void main(String[] args){

BIN
IntegerPrinterTest.class Datei anzeigen


+ 11
- 0
IntegerPrinterTest.ctxt Datei anzeigen

@@ -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
LargestInteger.class Datei anzeigen


+ 7
- 0
LargestInteger.ctxt Datei anzeigen

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

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

BIN
LargestIntegerTest.class Datei anzeigen


+ 9
- 0
LargestIntegerTest.ctxt Datei anzeigen

@@ -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
NormalizeAngle.class Datei anzeigen


+ 9
- 0
NormalizeAngle.ctxt Datei anzeigen

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

+ 2
- 2
NormalizeAngle.java Datei anzeigen

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

BIN
NormalizeAngleTest.class Datei anzeigen


+ 9
- 0
NormalizeAngleTest.ctxt Datei anzeigen

@@ -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
ShortCalculator.class Datei anzeigen


+ 17
- 0
ShortCalculator.ctxt Datei anzeigen

@@ -0,0 +1,17 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=
4
+comment1.target=ShortCalculator()
5
+comment2.params=args
6
+comment2.target=void\ main(java.lang.String[])
7
+comment3.params=first\ second
8
+comment3.target=short\ getSum(short,\ short)
9
+comment4.params=first\ second
10
+comment4.target=short\ getDifference(short,\ short)
11
+comment5.params=first\ second
12
+comment5.target=short\ getProduct(short,\ short)
13
+comment6.params=first\ second
14
+comment6.target=short\ getQuotient(short,\ short)
15
+comment7.params=first\ second
16
+comment7.target=short\ getRemainder(short,\ short)
17
+numComments=8

+ 56
- 1
ShortCalculator.java Datei anzeigen

@@ -1,5 +1,60 @@
1
- 
1
+// Write a program that reads in two numbers between 0 and 65535, 
2
+//stores them in short variables, and computes their unsigned sum, 
3
+//difference, product, quotient, and remainder , without converting 
4
+//them to int.
2 5
 
6
+import java.util.*;
3 7
 
4 8
 public class ShortCalculator {
9
+    short f;
10
+    short s;
11
+    public ShortCalculator(){
12
+        short first = f;
13
+        short second = s;
14
+    }    
15
+
16
+    public static void main(String[] args){
17
+        Scanner shortNum = new Scanner(System.in);
18
+        System.out.println("Enter first short");
19
+        short f = shortNum.nextShort();
20
+        System.out.println("Enter second short");
21
+        short s = shortNum.nextShort();
22
+        ShortCalculator shortCalc = new ShortCalculator();
23
+        shortCalc.getSum(f, s);
24
+        shortCalc.getDifference(f, s);
25
+        shortCalc.getProduct(f, s);
26
+        shortCalc.getQuotient(f, s);
27
+        shortCalc.getRemainder(f, s);
28
+    }
29
+
30
+    public short getSum(short first,short second){
31
+        short sum = (short)(first + second);
32
+        System.out.println("sum is "+ sum);
33
+        return sum;
34
+    }
35
+
36
+    public short getDifference(short first,short second){
37
+        short difference = (short)(first - second);
38
+        System.out.println("differece is "+ difference);
39
+        return difference;
40
+    }
41
+
42
+    public short getProduct(short first,short second){
43
+        short product = (short)(first * second);
44
+        System.out.println("product is "+ product);
45
+        return product;
46
+    }
47
+
48
+    public short getQuotient(short first,short second){
49
+        short quotient = (short)(first / second);
50
+        System.out.println("quotient is "+ quotient);
51
+        return quotient;
52
+    }
53
+
54
+    public short getRemainder(short first,short second){
55
+        short remainder = (short)(first % second); 
56
+        System.out.println("remainder is "+ remainder);
57
+        return remainder;
58
+    }
5 59
 }
60
+

BIN
ShortCalculatorTest.class Datei anzeigen


+ 3
- 0
ShortCalculatorTest.ctxt Datei anzeigen

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

+ 8
- 8
package.bluej Datei anzeigen

@@ -11,18 +11,18 @@ 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
18
-objectbench.height=101
14
+editor.fx.0.height=722
15
+editor.fx.0.width=800
16
+editor.fx.0.x=64
17
+editor.fx.0.y=23
18
+objectbench.height=216
19 19
 objectbench.width=1070
20 20
 package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
21
+package.divider.vertical=0.6646616541353384
22
+package.editor.height=435
23 23
 package.editor.width=968
24 24
 package.editor.x=59
25
-package.editor.y=82
25
+package.editor.y=24
26 26
 package.frame.height=723
27 27
 package.frame.width=1094
28 28
 package.numDependencies=4