Seth 6 years ago
parent
commit
2a9a289e42
3 changed files with 34 additions and 177 deletions
  1. 19
    118
      Calculator.java
  2. 0
    44
      MathMethods.java
  3. 15
    15
      package.bluej

+ 19
- 118
Calculator.java View File

@@ -29,31 +29,7 @@ class Calculator{
29 29
                 off = true;
30 30
                 System.out.println("Goodbye!!");
31 31
 
32
-            } else if(toDo.equalsIgnoreCase("memory")){
33
-                System.out.println("Read, Change or Clear?");
34
-                String mem = input1.next();
35
-                switch(mem) {
36
-                    case "Read" :
37
-                    result = Memory.memRead();
38
-                    Memory.printAns(String.valueOf(result));
39
-                    break;
40
-                    
41
-                    case "Change" :
42
-                    System.out.println("Enter number:");
43
-                    num1 = input1.nextDouble();
44
-                    result = Memory.memUpdate(num1);
45
-                    Memory.printAns(String.valueOf(result));
46
-                    break;
47
-                    
48
-                    case "Clear" :
49
-                    result = Memory.memClear();
50
-                    Memory.printAns(String.valueOf(result));
51
-                    break;
52
-                    
53
-                }
54
-            }
55
-        
56
-            
32
+            }                              
57 33
             else {
58 34
 
59 35
             //System.out.println("toDO is: " + toDo);
@@ -177,101 +153,26 @@ class Calculator{
177 153
                 calc.printAns(String.valueOf(result));
178 154
                 break; 
179 155
 
156
+                case "MR" :
157
+                result = Memory.memRead();
158
+                Memory.printAns(String.valueOf(result));
159
+                break;
160
+                    
161
+                case "M+" :
162
+                System.out.println("Enter number:");
163
+                num1 = input1.nextDouble();
164
+                result = Memory.memUpdate(num1);
165
+                Memory.printAns(String.valueOf(result));
166
+                break;
167
+                    
168
+                case "MC" :
169
+                result = Memory.memClear();
170
+                Memory.printAns(String.valueOf(result));
171
+                break;
172
+                    
173
+                
180 174
             }
181 175
         }
182 176
     }
183 177
 }
184 178
 }
185
-
186
-// /**
187
-// * Created by leon on 2/9/18.
188
-// */
189
-// public class Console {
190
-// Calculator calc = new Calculator();
191
-
192
-// public static void print(String output, Object... args) {
193
-// System.out.printf(output, args);
194
-// }
195
-
196
-// public static void println(String output, Object... args) {
197
-// print(output + "\n", args);
198
-// }
199
-
200
-// public static String getMethod() {
201
-// Scanner scanner = new Scanner(System.in);
202
-// String userInput = scanner.nextLine();
203
-// return userInput;
204
-// }
205
-
206
-// public static String switchStatment() {
207
-// Scanner scanner = new Scanner(System.in);
208
-// String ultimateAnswer = "";
209
-// Boolean turnOff = false;
210
-
211
-// switch (getMethod()) {
212
-// case "add" :
213
-// System.out.println("Enter your numbers:");
214
-// double userInput = scanner.nextDouble();
215
-// double nextInput = scanner.nextDouble();
216
-
217
-// double answer = Calculator.add(userInput, nextInput);
218
-// ultimateAnswer = Double.toString(answer);
219
-// return Double.toString(answer);
220
-
221
-// case "subtract" :
222
-// System.out.println("Enter your numbers:");
223
-// userInput = scanner.nextDouble();
224
-// nextInput = scanner.nextDouble();
225
-
226
-// answer = Calculator.subtract(userInput, nextInput);
227
-// ultimateAnswer = Double.toString(answer);
228
-// return ultimateAnswer;
229
-
230
-// case "multiply" :
231
-// System.out.println("Enter your numbers:");
232
-// userInput = scanner.nextDouble();
233
-// nextInput = scanner.nextDouble();
234
-
235
-// answer = Calculator.multiply(userInput, nextInput);
236
-// ultimateAnswer = Double.toString(answer);
237
-// return ultimateAnswer;
238
-
239
-// case "divide" :
240
-// System.out.println("Enter your numbers:");
241
-// userInput = scanner.nextDouble();
242
-// nextInput = scanner.nextDouble();
243
-
244
-// answer = Calculator.divide(userInput, nextInput);
245
-// ultimateAnswer = Double.toString(answer);
246
-// return ultimateAnswer;
247
-
248
-// case "Square Root" :
249
-
250
-// }
251
-// return ultimateAnswer;
252
-// }
253
-
254
-// /*public static String getStringInput(String prompt) {
255
-// Scanner scanner = new Scanner(System.in);
256
-// println(prompt);
257
-// String userInput = scanner.nextLine();
258
-// return userInput;
259
-// }
260
-
261
-// public static Integer getIntegerInput(String prompt) {
262
-// Scanner scanner = new Scanner(System.in);
263
-// println(prompt);
264
-// int userInput = scanner.nextInt();
265
-// return null;
266
-// }
267
-
268
-// public static Double getDoubleInput(String prompt) {
269
-// Scanner scanner = new Scanner(System.in);
270
-// println(prompt);
271
-// double userInput = scanner.nextDouble();
272
-// double nextInput = scanner.nextDouble();
273
-// double answer = Calculator.add(userInput, nextInput);
274
-// return answer;
275
-// }*/
276
-
277
-// }

+ 0
- 44
MathMethods.java View File

@@ -90,47 +90,3 @@ public class MathMethods
90 90
 
91 91
 }
92 92
 
93
-    
94
-    
95
-// public static double squareRoot(double n1) {
96
-// double result = Math.sqrt(x);
97
-// return result;
98
-// }
99
-
100
-// public static double invert(double n1) {
101
-// double result = x*-1;
102
-// return result;
103
-// }
104
-
105
-// public static double sin(double n1){
106
-// double result = Math.sin(x);
107
-// return result;
108
-// }
109
-
110
-// public static double iSin(double n1){
111
-// double result = Math.asin(x);
112
-// return result;
113
-// }
114
-
115
-// public static double degToRad(double n1) {
116
-// double result = Math.toRadians(x);
117
-// return result;
118
-// }
119
-
120
-// public static double radToDeg(double n1) {
121
-// double result = Math.toDegrees(x);
122
-// return result;
123
-// }
124
-
125
-// public static Double exponent(double n1, double n2){
126
-// return (Math.pow(n1, n2));
127
-// }
128
-
129
-// public static Double cosine(double n1){
130
-// return (Math.cos(n1));
131
-// }
132
-
133
-// public static Double invCosine(double n1){
134
-// return (Math.acos(n1));
135
-// }
136
-

+ 15
- 15
package.bluej View File

@@ -2,27 +2,27 @@
2 2
 dependency1.from=MathMethodsTest
3 3
 dependency1.to=MathMethods
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=Calculator
6
-dependency2.to=MathMethods
5
+dependency2.from=MemoryTest
6
+dependency2.to=Memory
7 7
 dependency2.type=UsesDependency
8 8
 dependency3.from=Calculator
9
-dependency3.to=Memory
9
+dependency3.to=MathMethods
10 10
 dependency3.type=UsesDependency
11
-dependency4.from=MemoryTest
11
+dependency4.from=Calculator
12 12
 dependency4.to=Memory
13 13
 dependency4.type=UsesDependency
14
-editor.fx.0.height=797
15
-editor.fx.0.width=1247
16
-editor.fx.0.x=87
17
-editor.fx.0.y=23
14
+editor.fx.0.height=814
15
+editor.fx.0.width=1191
16
+editor.fx.0.x=201
17
+editor.fx.0.y=-974
18 18
 objectbench.height=80
19 19
 objectbench.width=595
20 20
 package.divider.horizontal=0.5993322203672788
21 21
 package.divider.vertical=0.8465608465608465
22 22
 package.editor.height=473
23 23
 package.editor.width=493
24
-package.editor.x=102
25
-package.editor.y=23
24
+package.editor.x=-188
25
+package.editor.y=-610
26 26
 package.frame.height=625
27 27
 package.frame.width=619
28 28
 package.numDependencies=4
@@ -55,20 +55,20 @@ target3.name=Calculator
55 55
 target3.showInterface=false
56 56
 target3.type=ClassTarget
57 57
 target3.width=90
58
-target3.x=240
58
+target3.x=220
59 59
 target3.y=80
60 60
 target4.height=50
61 61
 target4.name=MathMethodsTest
62 62
 target4.showInterface=false
63 63
 target4.type=UnitTestTargetJunit4
64 64
 target4.width=110
65
-target4.x=170
66
-target4.y=280
65
+target4.x=90
66
+target4.y=250
67 67
 target5.association=MathMethodsTest
68 68
 target5.height=50
69 69
 target5.name=MathMethods
70 70
 target5.showInterface=false
71 71
 target5.type=ClassTarget
72 72
 target5.width=110
73
-target5.x=140
74
-target5.y=310
73
+target5.x=60
74
+target5.y=280