浏览代码

All test pass and also got done the ShortCalculator

nmaidanos 6 年前
父节点
当前提交
1f39e9f7aa
共有 13 个文件被更改,包括 200 次插入215 次删除
  1. 7
    7
      LargestInteger.ctxt
  2. 9
    9
      LargestIntegerTest.ctxt
  3. 二进制
      NormalizeAngle.class
  4. 9
    9
      NormalizeAngle.ctxt
  5. 2
    2
      NormalizeAngle.java
  6. 9
    9
      NormalizeAngleTest.ctxt
  7. 二进制
      ShortCalculator.class
  8. 7
    5
      ShortCalculator.ctxt
  9. 47
    62
      ShortCalculator.java
  10. 二进制
      ShortCalculatorTest.class
  11. 3
    3
      ShortCalculatorTest.ctxt
  12. 0
    2
      ShortCalculatorTest.java
  13. 107
    107
      package.bluej

+ 7
- 7
LargestInteger.ctxt 查看文件

@@ -1,7 +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
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
- 9
LargestIntegerTest.ctxt 查看文件

@@ -1,9 +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
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

二进制
NormalizeAngle.class 查看文件


+ 9
- 9
NormalizeAngle.ctxt 查看文件

@@ -1,9 +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
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 查看文件

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

+ 9
- 9
NormalizeAngleTest.ctxt 查看文件

@@ -1,9 +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
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

二进制
ShortCalculator.class 查看文件


+ 7
- 5
ShortCalculator.ctxt 查看文件

@@ -1,5 +1,7 @@
1
-#BlueJ class context
2
-comment0.target=ShortCalculator
3
-comment1.params=
4
-comment1.target=void\ ShortCalculator()
5
-numComments=2
1
+#BlueJ class context
2
+comment0.target=ShortCalculator
3
+comment1.params=
4
+comment1.target=void\ ShortCalculator()
5
+comment2.params=num
6
+comment2.target=boolean\ isInRange(short)
7
+numComments=3

+ 47
- 62
ShortCalculator.java 查看文件

@@ -3,70 +3,55 @@ import java.util.Scanner;
3 3
 
4 4
 public class ShortCalculator {
5 5
 
6
-
7
-    public static short S1;
8
-
9
-    public static short S2;
10
-
11
-
12
-    public static short sum;
13
-
14
-    public static short diff;
15
-
16
-    public static short product;
17
-
18
-    public static short quotient;
19
-
20
-    public static short remainder;
21
-
22
-
23
-
24
-
25
-
26 6
     public static void ShortCalculator(){
27 7
 
8
+        short S1;
9
+        short S2;
10
+        short sum;
11
+        short diff;
12
+        short product;
13
+        short quotient;
14
+        short remainder;
15
+        
28 16
         Scanner scanner = new Scanner(System.in);
29
-
30
-        System.out.println("Enter your first Short: ");
31
-
32
-        S1 = scanner.nextShort();
33
-
34
-
35
-
36
-        System.out.println("Enter your Second Short: ");
37
-
38
-        S2 = scanner.nextShort();
39
-
40
-
41
-
42
-        System.out.println(S1);
43
-
44
-        System.out.println(S2);
45
-
46
-
47
-
48
-        sum       = (short) (S1 + S2);
49
-
50
-        diff      = (short) (S1 - S2);
51
-
52
-        product   = (short) (S1 * S2);
53
-
54
-        quotient  = (short) (S1 / S2);
55
-
56
-        remainder = (short) (S1 % S2);
57
-
58
-
59
-
60
-        System.out.println("Sum is " + sum);
61
-
62
-        System.out.println("Diff is " + diff);
63
-
64
-        System.out.println("Product is " + product);
65
-
66
-        System.out.println("Quotient is " + quotient);
67
-
68
-        System.out.println("Remainder is " + remainder);
69
-
70
-
17
+        
18
+        boolean looping = true;
19
+        while(looping){
20
+        
21
+            System.out.println("Enter your first Short: ");
22
+            S1 = scanner.nextShort();    
23
+            
24
+            System.out.println("Enter your Second Short: ");
25
+            S2 = scanner.nextShort();
26
+            
27
+            if(isInRange(S1) && isInRange(S2)){
28
+                looping =  false;
29
+                 
30
+                sum       = (short) (S1 + S2);
31
+                diff      = (short) (S1 - S2);
32
+                product   = (short) (S1 * S2);
33
+                quotient  = (short) (S1 / S2);
34
+                remainder = (short) (S1 % S2);
35
+
36
+                System.out.println("Sum is "       + sum + " \n");
37
+                System.out.println("Diff is "      + diff + " \n");
38
+                System.out.println("Product is "   + product + " \n");
39
+                System.out.println("Quotient is "  + quotient + " \n");
40
+                System.out.println("Remainder is " + remainder + " \n");
41
+      
42
+            } else {
43
+                System.out.print("Both Number enter Must be inbetween 0 and 65535\n");
44
+            }
45
+        
46
+        }
47
+    }
48
+        
49
+    private static boolean isInRange(short num){
50
+        if(num > 0 && num < 65535){
51
+            return true;
52
+        } else {
53
+            return false;
71 54
         }
55
+    }
56
+        
72 57
 }

二进制
ShortCalculatorTest.class 查看文件


+ 3
- 3
ShortCalculatorTest.ctxt 查看文件

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

+ 0
- 2
ShortCalculatorTest.java 查看文件

@@ -1,5 +1,3 @@
1 1
  
2
-
3
-
4 2
 public class ShortCalculatorTest {
5 3
 }

+ 107
- 107
package.bluej 查看文件

@@ -1,107 +1,107 @@
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=22
15
-editor.fx.0.width=0
16
-editor.fx.0.x=40
17
-editor.fx.0.y=685
18
-objectbench.height=94
19
-objectbench.width=501
20
-package.divider.horizontal=0.6334164588528678
21
-package.divider.vertical=0.7765486725663717
22
-package.editor.height=344
23
-package.editor.width=680
24
-package.editor.x=556
25
-package.editor.y=63
26
-package.frame.height=510
27
-package.frame.width=822
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
1
+#BlueJ package file
2
+dependency1.from=FactorialTest
3
+dependency1.to=Factorial
4
+dependency1.type=UsesDependency
5
+dependency2.from=IntegerPrinterTest
6
+dependency2.to=IntegerPrinter
7
+dependency2.type=UsesDependency
8
+dependency3.from=LargestIntegerTest
9
+dependency3.to=LargestInteger
10
+dependency3.type=UsesDependency
11
+dependency4.from=NormalizeAngleTest
12
+dependency4.to=NormalizeAngle
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=155
19
+objectbench.width=868
20
+package.divider.horizontal=0.6334164588528678
21
+package.divider.vertical=0.7635036496350365
22
+package.editor.height=516
23
+package.editor.width=778
24
+package.editor.x=280
25
+package.editor.y=61
26
+package.frame.height=785
27
+package.frame.width=908
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=130
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=FactorialTest
96
+target8.showInterface=false
97
+target8.type=UnitTestTargetJunit4
98
+target8.width=100
99
+target8.x=410
100
+target8.y=260
101
+target9.height=50
102
+target9.name=NormalizeAngleTest
103
+target9.showInterface=false
104
+target9.type=UnitTestTargetJunit4
105
+target9.width=150
106
+target9.x=10
107
+target9.y=310