Browse Source

added switch mode for units and numbersystems

Jacob Andersen 6 years ago
parent
commit
f15fdc2542
2 changed files with 115 additions and 12 deletions
  1. 89
    0
      SwitchModes.java
  2. 26
    12
      package.bluej

+ 89
- 0
SwitchModes.java View File

@@ -0,0 +1,89 @@
1
+
2
+/**
3
+ * Write a description of class SwitchModes here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class SwitchModes
9
+{
10
+    // instance variables - replace the example below with your own
11
+    public static int displayMode=1;
12
+    public static int unitMode=1;
13
+
14
+    /**
15
+     * Constructor for objects of class SwitchModes
16
+     */
17
+    public SwitchModes()
18
+    {
19
+        // initialise instance variables
20
+    }
21
+
22
+    /**
23
+     * An example of a method - replace this comment with your own
24
+     *
25
+     * @param  y  a sample parameter for a method
26
+     * @return    the sum of x and y
27
+     */
28
+    
29
+public static void switchDisplayMode (String mode){
30
+mode.toLowerCase();
31
+    switch (mode) {
32
+            case "hex": { 
33
+                displayMode=1;
34
+                // call update display
35
+                break;
36
+            }
37
+            case "bin": { 
38
+                displayMode=2;
39
+                // call update display
40
+                break;
41
+            }
42
+            case "dec": { 
43
+                displayMode=3;
44
+                // call update display
45
+                break;
46
+            }case "oct": { 
47
+                displayMode=4;
48
+                // call update display
49
+                break;
50
+            }
51
+        }
52
+    }
53
+            
54
+    public static void switchDisplayMode(){
55
+        if (displayMode==4){
56
+            displayMode=1;
57
+            // call update display
58
+        } 
59
+        else {
60
+            displayMode++;
61
+            // call update display
62
+        }
63
+
64
+    }
65
+
66
+    public static void switchUnitsMode (String mode){
67
+        if (mode.toLowerCase()=="degrees") {
68
+            unitMode=1;
69
+            
70
+        } else if(mode.toLowerCase()=="radians")
71
+            unitMode=2;
72
+                
73
+
74
+    }
75
+
76
+    public static void switchUnitsMode(){
77
+        if (displayMode==4){
78
+            unitMode=1;
79
+            // call update display
80
+        } 
81
+        else {
82
+            unitMode++;
83
+            // call update display
84
+        }
85
+
86
+    }
87
+
88
+    
89
+}

+ 26
- 12
package.bluej View File

@@ -2,10 +2,10 @@
2 2
 dependency1.from=MainApplication
3 3
 dependency1.to=Console
4 4
 dependency1.type=UsesDependency
5
-editor.fx.0.height=717
6
-editor.fx.0.width=800
7
-editor.fx.0.x=480
8
-editor.fx.0.y=23
5
+editor.fx.0.height=0
6
+editor.fx.0.width=0
7
+editor.fx.0.x=0
8
+editor.fx.0.y=0
9 9
 objectbench.height=101
10 10
 objectbench.width=595
11 11
 package.divider.horizontal=0.6
@@ -17,7 +17,7 @@ package.editor.y=23
17 17
 package.frame.height=716
18 18
 package.frame.width=619
19 19
 package.numDependencies=1
20
-package.numTargets=2
20
+package.numTargets=4
21 21
 package.showExtends=true
22 22
 package.showUses=true
23 23
 project.charset=UTF-8
@@ -27,16 +27,30 @@ readme.width=47
27 27
 readme.x=10
28 28
 readme.y=10
29 29
 target1.height=50
30
-target1.name=Console
30
+target1.name=Memory
31 31
 target1.showInterface=false
32 32
 target1.type=ClassTarget
33 33
 target1.width=80
34
-target1.x=80
35
-target1.y=200
34
+target1.x=190
35
+target1.y=10
36 36
 target2.height=50
37
-target2.name=MainApplication
37
+target2.name=Console
38 38
 target2.showInterface=false
39 39
 target2.type=ClassTarget
40
-target2.width=120
41
-target2.x=70
42
-target2.y=70
40
+target2.width=80
41
+target2.x=80
42
+target2.y=200
43
+target3.height=50
44
+target3.name=SciCalculator
45
+target3.showInterface=false
46
+target3.type=ClassTarget
47
+target3.width=110
48
+target3.x=70
49
+target3.y=10
50
+target4.height=50
51
+target4.name=MainApplication
52
+target4.showInterface=false
53
+target4.type=ClassTarget
54
+target4.width=120
55
+target4.x=70
56
+target4.y=70