123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
-
- /**
-
- */
- 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.");
- 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;
- }
-
- }
|