Ver código fonte

Updated return values for methods

Trinh Tong 6 anos atrás
pai
commit
811c55cfba
2 arquivos alterados com 12 adições e 12 exclusões
  1. 8
    8
      MemoryFunc.java
  2. 4
    4
      package.bluej

+ 8
- 8
MemoryFunc.java Ver arquivo

@@ -28,12 +28,12 @@ public class MemoryFunc {
28 28
         
29 29
         while (!memoryOpt.equals("4")) {
30 30
             
31
-            memoryOpt = Console.getStringInput("Select option by typing the key. (ie 1 for M+)").toLowerCase();
31
+            memoryOpt = Console.getStringInput("Select option by typing the key. (ie 1 for M+)");
32 32
             
33 33
             if (memoryOpt.equals("1")) {
34 34
                 
35 35
                 Double newMemory = Console.getDoubleInput("Enter the value to store");
36
-                updateMemory(newMemory);
36
+                this.memory = updateMemory(newMemory);
37 37
                 break;
38 38
                 
39 39
             } else if (memoryOpt.equals("2")) {
@@ -54,16 +54,16 @@ public class MemoryFunc {
54 54
         }
55 55
     }
56 56
     
57
-    public void updateMemory(Double memoryInput) {
58
-        this.memory = memoryInput;
57
+    public Double updateMemory(Double memoryInput) {
58
+        return this.memory = memoryInput;
59 59
     }
60 60
     
61
-    public void clearMemory() {
62
-        this.memory = DEFAULT_MEMORY_VALUE;
61
+    public Double clearMemory() {
62
+        return this.memory = DEFAULT_MEMORY_VALUE;
63 63
     }
64 64
     
65
-    public void displayMemory() {
66
-        Console.println(memory.toString());
65
+    public Double displayMemory() {
66
+        return this.memory;
67 67
     }
68 68
     
69 69
 }

+ 4
- 4
package.bluej Ver arquivo

@@ -26,10 +26,10 @@ dependency8.type=UsesDependency
26 26
 dependency9.from=MemoryFunc
27 27
 dependency9.to=Console
28 28
 dependency9.type=UsesDependency
29
-editor.fx.0.height=722
30
-editor.fx.0.width=1120
31
-editor.fx.0.x=320
32
-editor.fx.0.y=119
29
+editor.fx.0.height=0
30
+editor.fx.0.width=0
31
+editor.fx.0.x=0
32
+editor.fx.0.y=0
33 33
 objectbench.height=214
34 34
 objectbench.width=595
35 35
 package.divider.horizontal=0.6