Quellcode durchsuchen

Completed Classes#

shakila vor 6 Jahren
Ursprung
Commit
bfe754520f

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

+ 14
- 3
Factorial.java Datei anzeigen

@@ -1,12 +1,23 @@
1
- 
2
-
3 1
 
2
+import java.util.Scanner;
4 3
 import java.math.BigInteger;
5 4
 
6 5
 public class Factorial {
7 6
 
8 7
     public BigInteger factorialOf(Integer value){
9
-        return null;
8
+
9
+        Scanner scanner = new Scanner(System.in);
10
+        System.out.println("Enter a number: ");
11
+        int userInput = scanner.nextInt();
12
+        int counter = userInput;
13
+        BigInteger result = BigInteger.ONE;
14
+        for(int i=1; i <counter; i++){
15
+            value = value*i;
16
+        }
17
+
18
+
19
+        System.out.println(value);
20
+        return result.multiply(BigInteger.valueOf(value));
10 21
     }
11 22
 
12 23
 }

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

+ 21
- 10
IntegerPrinter.java Datei anzeigen

@@ -1,21 +1,32 @@
1
- 
2
-
1
+import java.util.Scanner;
2
+import java.lang.Math;
3 3
 
4 4
 public class IntegerPrinter {
5
-
6
-    public String printIntegerAsBinary(int value){
7
-        return null;
5
+    int value = 0;
6
+    public static String printIntegerAsBinary(int value){
7
+        String binary = Integer.toBinaryString(value);
8
+        return binary;
8 9
     }
9 10
 
10
-    public String printIntegerAsOctal(int value){
11
-        return null;
11
+    public static String printIntegerAsOctal(int value){
12
+        String octal = Integer.toOctalString(value);
13
+        return octal;
12 14
     }
13 15
 
14
-    public String printIntegerAsHexadecimal(int value){
15
-        return null;
16
+    public static String printIntegerAsHexadecimal(int value){
17
+        String hex = Integer.toHexString(value);
18
+        return hex;
16 19
     }
17 20
 
18 21
     public static void main(String[] args){
19
-
22
+        Scanner in = new Scanner(System.in);
23
+        System.out.println("Please enter a number:");
24
+        int i = in.nextInt();
25
+        
26
+        
27
+        printIntegerAsBinary(i);
28
+        printIntegerAsOctal(i);
29
+        printIntegerAsHexadecimal(i);
20 30
     }
21 31
 }
32
+

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

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

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


+ 5
- 0
ShortCalculator.ctxt Datei anzeigen

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=number1\ number2
4
+comment1.target=void\ math(short,\ short)
5
+numComments=2

+ 21
- 1
ShortCalculator.java Datei anzeigen

@@ -1,5 +1,25 @@
1
- 
1
+ import java.util.Scanner;
2
+ import java.lang.Math;
2 3
 
3 4
 
4 5
 public class ShortCalculator {
6
+
7
+public static void math(short number1,short number2){
8
+    
9
+    Scanner scanner = new Scanner(System.in);
10
+    System.out.println("Enter the first number");
11
+    number1 = scanner.nextShort();
12
+    System.out.println("Enter second number");
13
+    number2 = scanner.nextShort();
14
+    
15
+    System.out.println(number1 + (double)number2);
16
+    System.out.println(number1 - (double)number2);
17
+    System.out.println(number1 * (double)number2);
18
+    System.out.println(number1/(double)number2);
19
+
20
+    
21
+    
22
+}
23
+
24
+
5 25
 }

BIN
ShortCalculatorTest.class Datei anzeigen


+ 13
- 0
ShortCalculatorTest.ctxt Datei anzeigen

@@ -0,0 +1,13 @@
1
+#BlueJ class context
2
+comment0.target=ShortCalculatorTest
3
+comment0.text=\n\ The\ test\ class\ ShortCalculatorTest.\n\n\ @author\ \ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=ShortCalculatorTest()
6
+comment1.text=\n\ Default\ constructor\ for\ test\ class\ ShortCalculatorTest\n
7
+comment2.params=
8
+comment2.target=void\ setUp()
9
+comment2.text=\n\ Sets\ up\ the\ test\ fixture.\n\n\ Called\ before\ every\ test\ case\ method.\n
10
+comment3.params=
11
+comment3.target=void\ tearDown()
12
+comment3.text=\n\ Tears\ down\ the\ test\ fixture.\n\n\ Called\ after\ every\ test\ case\ method.\n
13
+numComments=4

+ 21
- 2
ShortCalculatorTest.java Datei anzeigen

@@ -1,5 +1,24 @@
1
- 
2 1
 
3 2
 
4
-public class ShortCalculatorTest {
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+import org.junit.Assert;
8
+
9
+/**
10
+ * The test class ShortCalculatorTest.
11
+ *
12
+ * @author  (your name)
13
+ * @version (a version number or a date)
14
+ */
15
+public class ShortCalculatorTest
16
+{
17
+    @Test
18
+    public void addTest(){
19
+    //ShortCalculator shortCalculator = new ShortCalculator();
20
+    //double expected = 388;
21
+    //double actual = ShortCalculator.math(255,133);
22
+    Assert.assertEquals(388,ShortCalculator.math(255,133),0.01);
23
+}
5 24
 }

+ 15
- 15
package.bluej Datei anzeigen

@@ -11,19 +11,19 @@ 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
19
-objectbench.width=1070
20
-package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
14
+editor.fx.0.height=709
15
+editor.fx.0.width=800
16
+editor.fx.0.x=106
17
+editor.fx.0.y=23
18
+objectbench.height=99
19
+objectbench.width=637
20
+package.divider.horizontal=0.5996275605214153
21
+package.divider.vertical=0.837173579109063
22
+package.editor.height=538
23 23
 package.editor.width=968
24 24
 package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
25
+package.editor.y=23
26
+package.frame.height=709
27 27
 package.frame.width=1094
28 28
 package.numDependencies=4
29 29
 package.numTargets=10
@@ -47,8 +47,8 @@ target10.name=IntegerPrinterTest
47 47
 target10.showInterface=false
48 48
 target10.type=UnitTestTargetJunit4
49 49
 target10.width=140
50
-target10.x=10
51
-target10.y=370
50
+target10.x=510
51
+target10.y=130
52 52
 target2.height=50
53 53
 target2.name=NormalizeAngle
54 54
 target2.showInterface=false
@@ -61,8 +61,8 @@ target3.name=IntegerPrinter
61 61
 target3.showInterface=false
62 62
 target3.type=ClassTarget
63 63
 target3.width=110
64
-target3.x=10
65
-target3.y=130
64
+target3.x=530
65
+target3.y=50
66 66
 target4.height=50
67 67
 target4.name=ShortCalculator
68 68
 target4.showInterface=false