瀏覽代碼

Updated return values for methods

Trinh Tong 6 年之前
父節點
當前提交
811c55cfba
共有 2 個檔案被更改,包括 12 行新增12 行删除
  1. 8
    8
      MemoryFunc.java
  2. 4
    4
      package.bluej

+ 8
- 8
MemoryFunc.java 查看文件

@@ -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 查看文件

@@ -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