Selaa lähdekoodia

Merge branch 'master' of mdimarino/ZCW-MacroLabs-OOP-ScientificCalculator into master

trtong 6 vuotta sitten
vanhempi
commit
b738e021b3
4 muutettua tiedostoa jossa 106 lisäystä ja 99 poistoa
  1. 4
    1
      Console.java
  2. 9
    1
      RealAdvanced.java
  3. 8
    0
      RealAdvancedTest.java
  4. 85
    97
      package.bluej

+ 4
- 1
Console.java Näytä tiedosto

143
                     advAnswer = advCalc.absoluteValue(advInput1);
143
                     advAnswer = advCalc.absoluteValue(advInput1);
144
                 }else if (mode.equals("6")){
144
                 }else if (mode.equals("6")){
145
                     advAnswer = advCalc.sqrt(advInput1);
145
                     advAnswer = advCalc.sqrt(advInput1);
146
+                }else if (mode.equals("7")){
147
+                    advAnswer = advCalc.factorial(advInput1);
148
+             
146
 
149
 
147
-                }else if (mode.equals("7")) {
150
+                }else if (mode.equals("8")) {
148
                     break;
151
                     break;
149
                 }else{
152
                 }else{
150
                     Console.println("Invalid input");
153
                     Console.println("Invalid input");

+ 9
- 1
RealAdvanced.java Näytä tiedosto

20
             "4: Switch Sign of x" + "\n"+
20
             "4: Switch Sign of x" + "\n"+
21
             "5: Absolute Value of x" + "\n"+
21
             "5: Absolute Value of x" + "\n"+
22
             "6: Square Root of x" + "\n"+
22
             "6: Square Root of x" + "\n"+
23
-            "7: Return to Main Menu");
23
+            "7: Factorial x!"+"\n"+
24
+            "8: Return to Main Menu");
24
 
25
 
25
     }
26
     }
26
     // method to find x^2
27
     // method to find x^2
46
 public double sqrt(double x){
47
 public double sqrt(double x){
47
     return Math.sqrt(x);
48
     return Math.sqrt(x);
48
 }
49
 }
50
+public double factorial(double x){
51
+    double answer = 1;
52
+    for (double i = x; i >0; i--){
53
+        answer = answer * i;
54
+    }
55
+    return answer;
56
+}
49
 }
57
 }

+ 8
- 0
RealAdvancedTest.java Näytä tiedosto

81
         RealAdvanced realAdva1 = new RealAdvanced();
81
         RealAdvanced realAdva1 = new RealAdvanced();
82
         assertEquals(5.0, realAdva1.sqrt(25), 0.1);
82
         assertEquals(5.0, realAdva1.sqrt(25), 0.1);
83
     }
83
     }
84
+
85
+    @Test
86
+    public void factorialTest()
87
+    {
88
+        RealAdvanced realAdva1 = new RealAdvanced();
89
+        assertEquals(120.0, realAdva1.factorial(5), 0.1);
90
+    }
84
 }
91
 }
85
 
92
 
86
 
93
 
88
 
95
 
89
 
96
 
90
 
97
 
98
+

+ 85
- 97
package.bluej Näytä tiedosto

1
 #BlueJ package file
1
 #BlueJ package file
2
-dependency1.from=MainMenu
2
+dependency1.from=Basic
3
 dependency1.to=Console
3
 dependency1.to=Console
4
 dependency1.type=UsesDependency
4
 dependency1.type=UsesDependency
5
 dependency10.from=Console
5
 dependency10.from=Console
6
-<<<<<<< HEAD
7
-dependency10.to=RealAdvanced
6
+dependency10.to=MainMenu
8
 dependency10.type=UsesDependency
7
 dependency10.type=UsesDependency
9
 dependency11.from=Console
8
 dependency11.from=Console
10
-dependency11.to=SciCalc
9
+dependency11.to=Basic
11
 dependency11.type=UsesDependency
10
 dependency11.type=UsesDependency
12
 dependency12.from=Console
11
 dependency12.from=Console
13
-dependency12.to=MemoryFunc
12
+dependency12.to=RealAdvanced
14
 dependency12.type=UsesDependency
13
 dependency12.type=UsesDependency
15
 dependency13.from=Console
14
 dependency13.from=Console
16
-dependency13.to=SwitchDisplay
15
+dependency13.to=SciCalc
17
 dependency13.type=UsesDependency
16
 dependency13.type=UsesDependency
18
 dependency14.from=Console
17
 dependency14.from=Console
19
-dependency14.to=Trig
20
-dependency14.type=UsesDependency
21
-dependency15.from=SwitchDisplay
22
-dependency15.to=Console
23
-dependency15.type=UsesDependency
24
-dependency2.from=SciCalc
25
-dependency2.to=Console
26
-dependency2.type=UsesDependency
27
-dependency3.from=MainApplication
28
-=======
29
-dependency10.to=Basic
30
-dependency10.type=UsesDependency
31
-dependency11.from=Console
32
-dependency11.to=RealAdvanced
33
-dependency11.type=UsesDependency
34
-dependency12.from=Console
35
-dependency12.to=SciCalc
36
-dependency12.type=UsesDependency
37
-dependency13.from=Console
38
-dependency13.to=MemoryFunc
39
-dependency13.type=UsesDependency
40
-dependency14.from=Console
41
-dependency14.to=SwitchDisplay
18
+dependency14.to=MemoryFunc
42
 dependency14.type=UsesDependency
19
 dependency14.type=UsesDependency
43
 dependency15.from=Console
20
 dependency15.from=Console
44
-dependency15.to=Trig
21
+dependency15.to=SwitchDisplay
45
 dependency15.type=UsesDependency
22
 dependency15.type=UsesDependency
46
-dependency16.from=RealAdvancedTest
47
-dependency16.to=RealAdvanced
23
+dependency16.from=Console
24
+dependency16.to=Trig
48
 dependency16.type=UsesDependency
25
 dependency16.type=UsesDependency
49
-dependency2.from=SciCalc
50
-dependency2.to=Console
26
+dependency17.from=RealAdvancedTest
27
+dependency17.to=RealAdvanced
28
+dependency17.type=UsesDependency
29
+dependency2.from=TrigTest
30
+dependency2.to=Trig
51
 dependency2.type=UsesDependency
31
 dependency2.type=UsesDependency
52
-dependency3.from=MemoryFunc
53
->>>>>>> 49d5555735b5e26b8076429d9dd1666b4918738c
54
->>>>>>> 3fa2b863a93d1b5548a82c34b3920f059a52833d
55
-dependency3.to=Console
32
+dependency3.from=BasicTest
33
+dependency3.to=Basic
56
 dependency3.type=UsesDependency
34
 dependency3.type=UsesDependency
57
-dependency4.from=Trig
35
+dependency4.from=MainMenu
58
 dependency4.to=Console
36
 dependency4.to=Console
59
 dependency4.type=UsesDependency
37
 dependency4.type=UsesDependency
60
-dependency5.from=Basic
38
+dependency5.from=SciCalc
61
 dependency5.to=Console
39
 dependency5.to=Console
62
 dependency5.type=UsesDependency
40
 dependency5.type=UsesDependency
63
-<<<<<<< HEAD
64
-dependency6.from=RealAdvanced
65
-dependency6.to=Console
66
-dependency6.type=UsesDependency
67
-dependency7.from=MemoryFunc
68
-=======
69
-dependency6.from=SwitchDisplay
41
+dependency6.from=MemoryFunc
70
 dependency6.to=Console
42
 dependency6.to=Console
71
 dependency6.type=UsesDependency
43
 dependency6.type=UsesDependency
72
-dependency7.from=MainMenu
73
->>>>>>> 3fa2b863a93d1b5548a82c34b3920f059a52833d
44
+dependency7.from=Trig
74
 dependency7.to=Console
45
 dependency7.to=Console
75
 dependency7.type=UsesDependency
46
 dependency7.type=UsesDependency
76
-dependency8.from=Console
77
-dependency8.to=MainMenu
47
+dependency8.from=SwitchDisplay
48
+dependency8.to=Console
78
 dependency8.type=UsesDependency
49
 dependency8.type=UsesDependency
79
-dependency9.from=Console
80
-<<<<<<< HEAD
81
-dependency9.to=Basic
82
-=======
83
-dependency9.to=MainMenu
84
->>>>>>> 3fa2b863a93d1b5548a82c34b3920f059a52833d
50
+dependency9.from=RealAdvanced
51
+dependency9.to=Console
85
 dependency9.type=UsesDependency
52
 dependency9.type=UsesDependency
86
-editor.fx.0.height=749
53
+editor.fx.0.height=709
87
 editor.fx.0.width=1215
54
 editor.fx.0.width=1215
88
-editor.fx.0.x=144
89
-editor.fx.0.y=72
90
-objectbench.height=214
55
+editor.fx.0.x=60
56
+editor.fx.0.y=24
57
+objectbench.height=198
91
 objectbench.width=595
58
 objectbench.width=595
92
 package.divider.horizontal=0.6
59
 package.divider.horizontal=0.6
93
-package.divider.vertical=0.6847360912981455
94
-package.editor.height=473
60
+package.divider.vertical=0.685099846390169
61
+package.editor.height=439
95
 package.editor.width=493
62
 package.editor.width=493
96
 package.editor.x=35
63
 package.editor.x=35
97
-package.editor.y=59
98
-package.frame.height=759
64
+package.editor.y=23
65
+package.frame.height=709
99
 package.frame.width=619
66
 package.frame.width=619
100
-package.numDependencies=15
101
-package.numTargets=9
67
+package.numDependencies=17
68
+package.numTargets=12
102
 package.showExtends=true
69
 package.showExtends=true
103
 package.showUses=true
70
 package.showUses=true
104
 project.charset=UTF-8
71
 project.charset=UTF-8
114
 target1.width=80
81
 target1.width=80
115
 target1.x=320
82
 target1.x=320
116
 target1.y=180
83
 target1.y=180
84
+target10.height=50
85
+target10.name=Trig
86
+target10.showInterface=false
87
+target10.type=ClassTarget
88
+target10.width=80
89
+target10.x=320
90
+target10.y=70
91
+target11.height=50
92
+target11.name=SwitchDisplay
93
+target11.showInterface=false
94
+target11.type=ClassTarget
95
+target11.width=110
96
+target11.x=80
97
+target11.y=350
98
+target12.height=50
99
+target12.name=MainApplication
100
+target12.showInterface=false
101
+target12.type=ClassTarget
102
+target12.width=120
103
+target12.x=70
104
+target12.y=70
117
 target2.height=50
105
 target2.height=50
118
-target2.name=SciCalc
106
+target2.name=TrigTest
119
 target2.showInterface=false
107
 target2.showInterface=false
120
-target2.type=ClassTarget
108
+target2.type=UnitTestTargetJunit4
121
 target2.width=80
109
 target2.width=80
122
-target2.x=10
123
-target2.y=280
110
+target2.x=200
111
+target2.y=70
124
 target3.height=50
112
 target3.height=50
125
-target3.name=RealAdvanced
113
+target3.name=BasicTest
126
 target3.showInterface=false
114
 target3.showInterface=false
127
-target3.type=ClassTarget
128
-target3.width=110
129
-target3.x=170
130
-target3.y=10
115
+target3.type=UnitTestTargetJunit4
116
+target3.width=90
117
+target3.x=160
118
+target3.y=130
131
 target4.height=50
119
 target4.height=50
132
-target4.name=MemoryFunc
120
+target4.name=RealAdvancedTest
133
 target4.showInterface=false
121
 target4.showInterface=false
134
-target4.type=ClassTarget
135
-target4.width=110
136
-target4.x=210
137
-target4.y=350
122
+target4.type=UnitTestTargetJunit4
123
+target4.width=140
124
+target4.x=100
125
+target4.y=230
138
 target5.height=50
126
 target5.height=50
139
-target5.name=Console
127
+target5.name=MainMenu
140
 target5.showInterface=false
128
 target5.showInterface=false
141
 target5.type=ClassTarget
129
 target5.type=ClassTarget
142
-target5.width=80
130
+target5.width=90
143
 target5.x=70
131
 target5.x=70
144
-target5.y=170
132
+target5.y=10
145
 target6.height=50
133
 target6.height=50
146
-target6.name=Trig
134
+target6.name=SciCalc
147
 target6.showInterface=false
135
 target6.showInterface=false
148
 target6.type=ClassTarget
136
 target6.type=ClassTarget
149
 target6.width=80
137
 target6.width=80
150
-target6.x=320
151
-target6.y=70
138
+target6.x=10
139
+target6.y=280
152
 target7.height=50
140
 target7.height=50
153
-target7.name=SwitchDisplay
141
+target7.name=RealAdvanced
154
 target7.showInterface=false
142
 target7.showInterface=false
155
 target7.type=ClassTarget
143
 target7.type=ClassTarget
156
 target7.width=110
144
 target7.width=110
157
-target7.x=80
158
-target7.y=350
145
+target7.x=170
146
+target7.y=10
159
 target8.height=50
147
 target8.height=50
160
-target8.name=MainMenu
148
+target8.name=Console
161
 target8.showInterface=false
149
 target8.showInterface=false
162
 target8.type=ClassTarget
150
 target8.type=ClassTarget
163
-target8.width=90
151
+target8.width=80
164
 target8.x=70
152
 target8.x=70
165
-target8.y=10
153
+target8.y=170
166
 target9.height=50
154
 target9.height=50
167
-target9.name=MainApplication
155
+target9.name=MemoryFunc
168
 target9.showInterface=false
156
 target9.showInterface=false
169
 target9.type=ClassTarget
157
 target9.type=ClassTarget
170
-target9.width=120
171
-target9.x=70
172
-target9.y=70
158
+target9.width=110
159
+target9.x=210
160
+target9.y=350