Преглед изворни кода

Broke down menu to methods

Trinh Tong пре 6 година
родитељ
комит
ed5bc869bc
2 измењених фајлова са 50 додато и 39 уклоњено
  1. 3
    39
      SciCalc.java
  2. 47
    0
      SwitchDisplay.java

+ 3
- 39
SciCalc.java Прегледај датотеку

@@ -10,55 +10,19 @@
10 10
 */
11 11
 public class SciCalc 
12 12
 {
13
-
14
-    private double memory = 0;
15
-
16
-    /**
17
-     * Switch Display Mode method 
18
-     * -> binary, octal, decimal, hexadecimal
19
-     * switchDisplayMode() rotates through the options
20
-     * switchDisplayMode(String mode) sets the display to the mode given
21
-     */
22
-    public void switchDisplay(String mode)
23
-    {
24
-        int baseInput = Console.getIntegerInput("Enter an integer to see the base conversions.");
25
-        
26
-        Console.println("Display Options" 
27
-                         + "\nBinary: " + null
28
-                         + "\nOctal: " + null
29
-                         + "\nDecimal: " + null
30
-                         + "\nHexadecimal: " + null
31
-                         + "\n");
32
-        
33
-        mode = Console.getStringInput("Enter the base option to display.");
34
-        if (mode.toLowerCase().equals("binary") == true) {
35
-            
36
-        } else if (mode.toLowerCase().equals("octal") == true) {
37
-            
38
-        }
39
-        
40
-
41
-    }
42
-    
43
-    /**
44
-     * Converts the user input into octal and returns a string of that octal.
45
-     */
46
-    public String toOctal(int userInput) {
47
-        
48
-        return Integer.toOctalString(userInput);
49
-        
13
+    public void toSwitchDisplay() {
14
+        SwitchDisplay switchDisplayMenu =  new SwitchDisplay();
50 15
     }
51 16
     
52 17
     public void toMemory() {
53 18
         MemoryFunc memoryMenu = new MemoryFunc();
54 19
     }
55 20
     
56
-    
57 21
     /**
58 22
      * To Trig -
59 23
      * sends user to trig functions of the calculator
60 24
      */
61
-    public void toTrig(int y)
25
+     public void toTrig(int y)
62 26
     {
63 27
         // calls the trig menu
64 28
         Trig trigMenu = new Trig();

+ 47
- 0
SwitchDisplay.java Прегледај датотеку

@@ -0,0 +1,47 @@
1
+
2
+/**
3
+ * Write a description of class SwitchDisplay here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class SwitchDisplay
9
+{
10
+    // instance variables - replace the example below with your own
11
+
12
+    /**
13
+     * Switch Display Mode method 
14
+     * -> binary, octal, decimal, hexadecimal
15
+     * switchDisplayMode() rotates through the options
16
+     * switchDisplayMode(String mode) sets the display to the mode given
17
+     */
18
+    public void switchDisplay(String mode)
19
+    {
20
+        int baseInput = Console.getIntegerInput("Enter an integer to see the base conversions.");
21
+        
22
+        Console.println("Display Options" 
23
+                         + "\nBinary: " + null
24
+                         + "\nOctal: " + null
25
+                         + "\nDecimal: " + null
26
+                         + "\nHexadecimal: " + null
27
+                         + "\n");
28
+        
29
+        mode = Console.getStringInput("Enter the base option to display.");
30
+        if (mode.toLowerCase().equals("binary") == true) {
31
+            
32
+        } else if (mode.toLowerCase().equals("octal") == true) {
33
+            
34
+        }
35
+        
36
+
37
+    }
38
+    
39
+    /**
40
+     * Converts the user input into octal and returns a string of that octal.
41
+     */
42
+    public String toOctal(int userInput) {
43
+        
44
+        return Integer.toOctalString(userInput);
45
+        
46
+    }
47
+}