Browse Source

finished lab

William Simkins 6 years ago
parent
commit
588c83b475

BIN
Factorial.class View File


+ 5
- 0
Factorial.ctxt View File

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

+ 5
- 2
Factorial.java View File

@@ -1,4 +1,3 @@
1
- 
2 1
 
3 2
 
4 3
 import java.math.BigInteger;
@@ -6,7 +5,11 @@ import java.math.BigInteger;
6 5
 public class Factorial {
7 6
 
8 7
     public BigInteger factorialOf(Integer value){
9
-        return null;
8
+       BigInteger biginteger = BigInteger.valueOf(1);
9
+       for (int i = 2; i <= value; i++){
10
+             biginteger = biginteger.multiply(BigInteger.valueOf(i));
11
+        }
12
+       return biginteger;
10 13
     }
11 14
 
12 15
 }

BIN
FactorialTest.class View File


+ 7
- 0
FactorialTest.ctxt View File

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


+ 11
- 0
IntegerPrinter.ctxt View File

@@ -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
- 3
IntegerPrinter.java View File

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

BIN
IntegerPrinterTest.class View File


+ 11
- 0
IntegerPrinterTest.ctxt View File

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


+ 7
- 0
LargestInteger.ctxt View File

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

+ 8
- 5
LargestInteger.java View File

@@ -1,13 +1,16 @@
1
- 
2
-
3
-
1
+import java.util.Scanner;
4 2
 public class LargestInteger {
5 3
 
6 4
     public Integer findLargestNumberUsingConditional(Integer[] integers){
7
-        return null;
5
+        int largestNumber = integers[0];
6
+        for(int i = 1; i < integers.length; i++){
7
+            if(integers[i] > largestNumber)
8
+                largestNumber = integers[i];
9
+        }
10
+        return largestNumber;
8 11
     }
9 12
 
10 13
     public Integer findLargestNumberUsingMathMax(Integer[] integers){
11
-        return null;
14
+         return Math.max(integers[0], Math.max(integers[1], integers[2]));
12 15
     }
13 16
 }

BIN
LargestIntegerTest.class View File


+ 9
- 0
LargestIntegerTest.ctxt View File

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


+ 9
- 0
NormalizeAngle.ctxt View File

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

+ 3
- 3
NormalizeAngle.java View File

@@ -1,14 +1,14 @@
1 1
  
2
-
2
+import java.util.Scanner;
3 3
 
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 View File


+ 9
- 0
NormalizeAngleTest.ctxt View File

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

+ 0
- 0
README.TXT View File


BIN
ShortCalculator.class View File


+ 5
- 0
ShortCalculator.ctxt View File

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

+ 14
- 1
ShortCalculator.java View File

@@ -1,5 +1,18 @@
1 1
  
2
-
2
+import java.util.Scanner;
3 3
 
4 4
 public class ShortCalculator {
5
+    
6
+    public void shortValue(short num1, short num2){
7
+        Scanner scanner = new Scanner(System.in);
8
+        System.out.println("Enter first number:");
9
+        num1 = scanner.nextShort();
10
+        System.out.println("Enter second number:");
11
+        num2 = scanner.nextShort();
12
+        
13
+        System.out.println(num1 + (float)num2);
14
+        System.out.println(num1 - (float)num2);
15
+        System.out.println(num1 * (float)num2);
16
+        System.out.println(num1 / (float)num2);
17
+    }
5 18
 }

BIN
ShortCalculatorTest.class View File


+ 3
- 0
ShortCalculatorTest.ctxt View File

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

+ 5
- 1
ShortCalculatorTest.java View File

@@ -1,5 +1,9 @@
1
- 
1
+
2 2
 
3 3
 
4 4
 public class ShortCalculatorTest {
5
+   
6
+
5 7
 }
8
+
9
+

+ 12
- 12
package.bluej View File

@@ -5,24 +5,24 @@ dependency1.type=UsesDependency
5 5
 dependency2.from=NormalizeAngleTest
6 6
 dependency2.to=NormalizeAngle
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=FactorialTest
9
-dependency3.to=Factorial
8
+dependency3.from=IntegerPrinterTest
9
+dependency3.to=IntegerPrinter
10 10
 dependency3.type=UsesDependency
11
-dependency4.from=IntegerPrinterTest
12
-dependency4.to=IntegerPrinter
11
+dependency4.from=FactorialTest
12
+dependency4.to=Factorial
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
+editor.fx.0.height=722
15
+editor.fx.0.width=800
16
+editor.fx.0.x=225
17
+editor.fx.0.y=23
18 18
 objectbench.height=101
19 19
 objectbench.width=1070
20 20
 package.divider.horizontal=0.6
21 21
 package.divider.vertical=0.837593984962406
22 22
 package.editor.height=550
23 23
 package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
24
+package.editor.x=0
25
+package.editor.y=23
26 26
 package.frame.height=723
27 27
 package.frame.width=1094
28 28
 package.numDependencies=4
@@ -54,8 +54,8 @@ target2.name=NormalizeAngle
54 54
 target2.showInterface=false
55 55
 target2.type=ClassTarget
56 56
 target2.width=120
57
-target2.x=70
58
-target2.y=70
57
+target2.x=240
58
+target2.y=100
59 59
 target3.height=50
60 60
 target3.name=IntegerPrinter
61 61
 target3.showInterface=false