Przeglądaj źródła

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

William Brown 6 lat temu
rodzic
commit
ace758aa98
3 zmienionych plików z 78 dodań i 21 usunięć
  1. 38
    0
      Memory.java
  2. 12
    0
      opSwitch.java
  3. 28
    21
      package.bluej

+ 38
- 0
Memory.java Wyświetl plik

@@ -0,0 +1,38 @@
1
+
2
+/**
3
+ * Write a description of class Memory here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Memory
9
+{
10
+    // instance variables - replace the example below with your own
11
+
12
+    /**
13
+     * Constructor for objects of class Memory
14
+     */
15
+    public Memory()
16
+    {
17
+    }
18
+ 
19
+    public static double memory[] = new double[1];
20
+    
21
+    public static void addMemory(double num){
22
+        memory[0] = num;
23
+        System.out.println("Added "+ num + " to memory.");
24
+    }
25
+    
26
+    public static double resetMemory(){
27
+        memory[0] = 0;
28
+        simpleOp.currentNumber = 0;
29
+        return simpleOp.currentNumber;
30
+    }
31
+    
32
+    public static double recallMemory(){
33
+        //simpleOp.currentNumber = memory[0];
34
+        //System.out.println(memory[0]);
35
+        simpleOp.currentNumber = memory[0];
36
+        return simpleOp.currentNumber;
37
+    }
38
+}

+ 12
- 0
opSwitch.java Wyświetl plik

@@ -28,6 +28,9 @@ public class opSwitch
28 28
                 +"quit"+"\n"
29 29
                 +"clear"+"\n"
30 30
                 +"reset"+"\n"
31
+                +"M+"+"\n"
32
+                +"MC"+"\n"
33
+                +"MRC"+"\n"
31 34
                 +"x rooted WIP"+"\n"
32 35
                 +"log WIP"+"\n"
33 36
                 +"ln WIP"+"\n"
@@ -82,6 +85,15 @@ public class opSwitch
82 85
             // default:
83 86
                 // System.out.println("You have not provided valid input. Please enter \"?\" for a list of commands.");
84 87
                 // break;
88
+            case "M+":
89
+                Memory.addMemory(op.currentNumber);
90
+                break;
91
+            case "MC":
92
+                Memory.resetMemory();
93
+                break;
94
+            case "MRC":
95
+                Memory.recallMemory();
96
+                break;
85 97
             case "x rooted":
86 98
                 break;
87 99
             case "log":

+ 28
- 21
package.bluej Wyświetl plik

@@ -2,22 +2,22 @@
2 2
 dependency1.from=ConsoleTest
3 3
 dependency1.to=Console
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=opSwitch
5
+dependency2.from=Console
6 6
 dependency2.to=simpleOp
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=opSwitch
9
-dependency3.to=Console
8
+dependency3.from=Console
9
+dependency3.to=opSwitch
10 10
 dependency3.type=UsesDependency
11
-dependency4.from=Console
11
+dependency4.from=MainApplication
12 12
 dependency4.to=simpleOp
13 13
 dependency4.type=UsesDependency
14
-dependency5.from=Console
15
-dependency5.to=opSwitch
14
+dependency5.from=MainApplication
15
+dependency5.to=Console
16 16
 dependency5.type=UsesDependency
17
-dependency6.from=MainApplication
17
+dependency6.from=opSwitch
18 18
 dependency6.to=simpleOp
19 19
 dependency6.type=UsesDependency
20
-dependency7.from=MainApplication
20
+dependency7.from=opSwitch
21 21
 dependency7.to=Console
22 22
 dependency7.type=UsesDependency
23 23
 editor.fx.0.height=711
@@ -30,12 +30,12 @@ package.divider.horizontal=0.6
30 30
 package.divider.vertical=0.6845329249617151
31 31
 package.editor.height=424
32 32
 package.editor.width=342
33
-package.editor.x=6
34
-package.editor.y=24
33
+package.editor.x=0
34
+package.editor.y=23
35 35
 package.frame.height=711
36 36
 package.frame.width=468
37 37
 package.numDependencies=7
38
-package.numTargets=5
38
+package.numTargets=6
39 39
 package.showExtends=true
40 40
 package.showUses=true
41 41
 project.charset=UTF-8
@@ -67,16 +67,23 @@ target3.width=80
67 67
 target3.x=30
68 68
 target3.y=170
69 69
 target4.height=50
70
-target4.name=ConsoleTest
70
+target4.name=Trigonometry
71 71
 target4.showInterface=false
72
-target4.type=UnitTestTargetJunit4
73
-target4.width=80
74
-target4.x=130
75
-target4.y=80
72
+target4.type=ClassTarget
73
+target4.width=110
74
+target4.x=40
75
+target4.y=280
76 76
 target5.height=50
77
-target5.name=MainApplication
77
+target5.name=ConsoleTest
78 78
 target5.showInterface=false
79
-target5.type=ClassTarget
80
-target5.width=120
81
-target5.x=210
82
-target5.y=10
79
+target5.type=UnitTestTargetJunit4
80
+target5.width=80
81
+target5.x=130
82
+target5.y=80
83
+target6.height=50
84
+target6.name=MainApplication
85
+target6.showInterface=false
86
+target6.type=ClassTarget
87
+target6.width=120
88
+target6.x=210
89
+target6.y=10