Browse Source

Updated methods

Trinh Tong 6 years ago
parent
commit
54331f2395
3 changed files with 26 additions and 21 deletions
  1. 6
    1
      MainApplication.java
  2. 10
    10
      MemoryFunc.java
  3. 10
    10
      package.bluej

+ 6
- 1
MainApplication.java View File

12
         MemoryFunc memory = new MemoryFunc();
12
         MemoryFunc memory = new MemoryFunc();
13
         SwitchDisplay baseChange = new SwitchDisplay();
13
         SwitchDisplay baseChange = new SwitchDisplay();
14
         
14
         
15
+        // Stored memory value should be able to be used throughout whole application
16
+        Double memoryValue = memory.memory;
17
+        
18
+        // if any input = "m", that input now = the memory value
19
+        
15
         // Menu Input
20
         // Menu Input
16
         String menuInput = " ";
21
         String menuInput = " ";
17
         // Giant while loop that links back to main menu
22
         // Giant while loop that links back to main menu
18
-        while (!menuInput.equals(4)) {
23
+        while (!menuInput.equals("4")) {
19
             mainMenu.mainMenuDisplay();
24
             mainMenu.mainMenuDisplay();
20
             menuInput = Console.getStringInput("Enter the calculator you want to use by key. (ie. 1 for basic, etc.)");
25
             menuInput = Console.getStringInput("Enter the calculator you want to use by key. (ie. 1 for basic, etc.)");
21
            
26
            

+ 10
- 10
MemoryFunc.java View File

3
 
3
 
4
  */
4
  */
5
 public class MemoryFunc {
5
 public class MemoryFunc {
6
-    private Double memory;
6
+    public Double memory;
7
     public static final Double DEFAULT_MEMORY_VALUE = new Double(0);
7
     public static final Double DEFAULT_MEMORY_VALUE = new Double(0);
8
 
8
 
9
     public MemoryFunc() {
9
     public MemoryFunc() {
19
     public void memoryMenu() {
19
     public void memoryMenu() {
20
         
20
         
21
         Console.println("Memory Menu"
21
         Console.println("Memory Menu"
22
-                         + "\nM+: Update stored memory value"
23
-                         + "\nMC: Clear to default memory value"
24
-                         + "\nMCR: Display stored memory value"
25
-                         + "\nCancel: Returns to Main Menu");
22
+                         + "\n1: M+ - Update stored memory value"
23
+                         + "\n2: nMC - Clear to default memory value"
24
+                         + "\n3: nMCR - Display stored memory value"
25
+                         + "\n4: Cancel - Returns to Main Menu");
26
                          
26
                          
27
         String memoryOpt = "";
27
         String memoryOpt = "";
28
         
28
         
29
-        while (!memoryOpt.equals("cancel")) {
29
+        while (!memoryOpt.equals("4")) {
30
             
30
             
31
-            memoryOpt = Console.getStringInput("Select option by typing the key").toLowerCase();
31
+            memoryOpt = Console.getStringInput("Select option by typing the key. (ie 1 for M+)").toLowerCase();
32
             
32
             
33
-            if (memoryOpt.equals("m+")) {
33
+            if (memoryOpt.equals("1")) {
34
                 
34
                 
35
                 Double newMemory = Console.getDoubleInput("Enter the value to store");
35
                 Double newMemory = Console.getDoubleInput("Enter the value to store");
36
                 updateMemory(newMemory);
36
                 updateMemory(newMemory);
37
                 break;
37
                 break;
38
                 
38
                 
39
-            } else if (memoryOpt.equals("mc")) {
39
+            } else if (memoryOpt.equals("2")) {
40
                 
40
                 
41
                 clearMemory();
41
                 clearMemory();
42
                 break;
42
                 break;
43
                 
43
                 
44
-            } else if (memoryOpt.equals("mcr")) {
44
+            } else if (memoryOpt.equals("3")) {
45
                 
45
                 
46
                 displayMemory();
46
                 displayMemory();
47
                 break;
47
                 break;

+ 10
- 10
package.bluej View File

1
 #BlueJ package file
1
 #BlueJ package file
2
-dependency1.from=MemoryFunc
2
+dependency1.from=MainMenu
3
 dependency1.to=Console
3
 dependency1.to=Console
4
 dependency1.type=UsesDependency
4
 dependency1.type=UsesDependency
5
-dependency2.from=MainMenu
5
+dependency2.from=SwitchDisplay
6
 dependency2.to=Console
6
 dependency2.to=Console
7
 dependency2.type=UsesDependency
7
 dependency2.type=UsesDependency
8
-dependency3.from=SwitchDisplay
8
+dependency3.from=SciCalc
9
 dependency3.to=Console
9
 dependency3.to=Console
10
 dependency3.type=UsesDependency
10
 dependency3.type=UsesDependency
11
-dependency4.from=SciCalc
12
-dependency4.to=Console
11
+dependency4.from=MainApplication
12
+dependency4.to=MainMenu
13
 dependency4.type=UsesDependency
13
 dependency4.type=UsesDependency
14
 dependency5.from=MainApplication
14
 dependency5.from=MainApplication
15
-dependency5.to=MainMenu
15
+dependency5.to=SciCalc
16
 dependency5.type=UsesDependency
16
 dependency5.type=UsesDependency
17
 dependency6.from=MainApplication
17
 dependency6.from=MainApplication
18
-dependency6.to=SciCalc
18
+dependency6.to=MemoryFunc
19
 dependency6.type=UsesDependency
19
 dependency6.type=UsesDependency
20
 dependency7.from=MainApplication
20
 dependency7.from=MainApplication
21
-dependency7.to=MemoryFunc
21
+dependency7.to=SwitchDisplay
22
 dependency7.type=UsesDependency
22
 dependency7.type=UsesDependency
23
 dependency8.from=MainApplication
23
 dependency8.from=MainApplication
24
-dependency8.to=SwitchDisplay
24
+dependency8.to=Console
25
 dependency8.type=UsesDependency
25
 dependency8.type=UsesDependency
26
-dependency9.from=MainApplication
26
+dependency9.from=MemoryFunc
27
 dependency9.to=Console
27
 dependency9.to=Console
28
 dependency9.type=UsesDependency
28
 dependency9.type=UsesDependency
29
 editor.fx.0.height=722
29
 editor.fx.0.height=722