|
@@ -9,6 +9,8 @@ public class Calculator
|
9
|
9
|
{
|
10
|
10
|
public static void runCommandLoop() {
|
11
|
11
|
Display display = new Display();
|
|
12
|
+ Memory memory = new Memory();
|
|
13
|
+ memory.resetMemory();
|
12
|
14
|
String initial = Console.getStringInput("Enter number");
|
13
|
15
|
display.setDisplay(initial);
|
14
|
16
|
while (true) {
|
|
@@ -86,6 +88,19 @@ public class Calculator
|
86
|
88
|
Console.println(Double.toString(out));
|
87
|
89
|
display.setDisplay(Double.toString(out));
|
88
|
90
|
}
|
|
91
|
+ if (command.equalsIgnoreCase("m+")) {
|
|
92
|
+ memory.addMemory(display.getDisplay());
|
|
93
|
+ display.setDisplay(memory.recallMemory());
|
|
94
|
+ Console.println(display.getDisplay());
|
|
95
|
+ }
|
|
96
|
+ if (command.equalsIgnoreCase("mrc")) {
|
|
97
|
+ Console.println(memory.recallMemory());
|
|
98
|
+ display.setDisplay(memory.recallMemory());
|
|
99
|
+ }
|
|
100
|
+ if (command.equalsIgnoreCase("mc")) {
|
|
101
|
+ memory.resetMemory();
|
|
102
|
+ Console.println(display.getDisplay());
|
|
103
|
+ }
|
89
|
104
|
/*String s = Console.getStringInput("Enter a string");
|
90
|
105
|
Integer i = Console.getIntegerInput("Enter an integer");
|
91
|
106
|
Double d = Console.getDoubleInput("Enter a double.");
|