12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
-
- /**
-
- */
- public class MemoryFunc {
- public Double memory;
- public Boolean memoryChanged;
- public static final Double DEFAULT_MEMORY_VALUE = new Double(0);
-
- public MemoryFunc() {
- this.memory = DEFAULT_MEMORY_VALUE;
- this.memoryChanged = false;
- }
-
- /**
- * Menu
- * Clear
- * Print
- * Update
- */
-
- public void memoryMenu() {
-
- Console.println("Memory Menu"
- + "\n1: M+ - Update stored memory value"
- + "\n2: MC - Clear to default memory value"
- + "\n3: MCR - Display stored memory value"
- + "\n4: Cancel - Returns to Main Menu");
-
- String memoryOpt = "";
-
- while (!memoryOpt.equals("4")) {
-
- memoryOpt = Console.getStringInput("Select option by typing the key. (ie. 1 for M+)");
-
- if (memoryOpt.equals("1")) {
-
- Double newMemory = Console.getDoubleInput("Enter the value to store");
- this.memory = updateMemory(newMemory);
- this.memoryChanged = true;
- break;
-
- } else if (memoryOpt.equals("2")) {
-
- clearMemory();
- Console.println("Memory cleared.");
- this.memoryChanged = false;
- break;
-
- } else if (memoryOpt.equals("3")) {
-
- Console.println("Stored Value: " + displayMemory());
- break;
-
- } else {
-
- Console.println("Invalid Option");
-
- }
- }
- }
-
- public Double updateMemory(Double memoryInput) {
- return this.memory = memoryInput;
- }
-
- public Double clearMemory() {
- return this.memory = DEFAULT_MEMORY_VALUE;
- }
-
- public Double displayMemory() {
- return this.memory;
- }
-
- }
|