Explorar el Código

classes for switching display modes and general display updated

Jacob Andersen hace 6 años
padre
commit
c04a30fede
Se han modificado 3 ficheros con 119 adiciones y 42 borrados
  1. 30
    15
      SwitchModes.java
  2. 45
    0
      UpdateDisplay.java
  3. 44
    27
      package.bluej

+ 30
- 15
SwitchModes.java Ver fichero

@@ -8,8 +8,26 @@
8 8
 public class SwitchModes
9 9
 {
10 10
     // instance variables - replace the example below with your own
11
-    public static int displayMode=1;
12
-    public static int unitMode=1;
11
+    private int displayMode=1;
12
+    private int unitMode=1;
13
+
14
+    SwitchModes sm = new SwitchModes();
15
+
16
+    public int getDisplayMode(){
17
+        return displayMode;
18
+    }
19
+
20
+    public void setDisplayMode(int mode){
21
+        displayMode=mode;
22
+    }
23
+
24
+    public int getUnitMode(){
25
+        return unitMode;
26
+    }
27
+
28
+    public void setUnitMode(int mode){
29
+        unitMode=mode;
30
+    }
13 31
 
14 32
     /**
15 33
      * Constructor for objects of class SwitchModes
@@ -25,10 +43,10 @@ public class SwitchModes
25 43
      * @param  y  a sample parameter for a method
26 44
      * @return    the sum of x and y
27 45
      */
28
-    
29
-public static void switchDisplayMode (String mode){
30
-mode.toLowerCase();
31
-    switch (mode) {
46
+
47
+    public void switchDisplayMode (String mode){
48
+        mode.toLowerCase();
49
+        switch (mode) {
32 50
             case "hex": { 
33 51
                 displayMode=1;
34 52
                 // call update display
@@ -50,8 +68,8 @@ mode.toLowerCase();
50 68
             }
51 69
         }
52 70
     }
53
-            
54
-    public static void switchDisplayMode(){
71
+
72
+    public void switchDisplayMode(){
55 73
         if (displayMode==4){
56 74
             displayMode=1;
57 75
             // call update display
@@ -63,18 +81,16 @@ mode.toLowerCase();
63 81
 
64 82
     }
65 83
 
66
-    public static void switchUnitsMode (String mode){
84
+    public void switchUnitsMode (String mode){
67 85
         if (mode.toLowerCase()=="degrees") {
68 86
             unitMode=1;
69
-            
87
+
70 88
         } else if(mode.toLowerCase()=="radians")
71 89
             unitMode=2;
72
-                
73 90
 
74 91
     }
75
-
76
-    public static void switchUnitsMode(){
77
-        if (displayMode==4){
92
+    public void switchUnitsMode(){
93
+        if (unitMode==2){
78 94
             unitMode=1;
79 95
             // call update display
80 96
         } 
@@ -85,5 +101,4 @@ mode.toLowerCase();
85 101
 
86 102
     }
87 103
 
88
-    
89 104
 }

+ 45
- 0
UpdateDisplay.java Ver fichero

@@ -0,0 +1,45 @@
1
+
2
+/**
3
+ * Write a description of class UpdateDisplay here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class UpdateDisplay
9
+{
10
+    // instance variables - replace the example below with your own
11
+    private int x;
12
+
13
+    /**
14
+     * Constructor for objects of class UpdateDisplay
15
+     */
16
+    public UpdateDisplay(Double displayNumber)
17
+    {
18
+       
19
+        // initialise instance variables
20
+        //x = 0;
21
+    }
22
+
23
+    /**
24
+     * An example of a method - replace this comment with your own
25
+     *
26
+     * @param  y  a sample parameter for a method
27
+     * @return    the sum of x and y
28
+     */
29
+    
30
+    SwitchModes sm = new SwitchModes();
31
+    
32
+    public String UpdateDisplay(Double displayNumber)
33
+    {
34
+     String str="";
35
+     
36
+     
37
+     // update number system based on display mode variable (see SwitchModes class)
38
+     
39
+     
40
+     
41
+     return str;   
42
+    }
43
+}
44
+
45
+

+ 44
- 27
package.bluej Ver fichero

@@ -2,22 +2,25 @@
2 2
 dependency1.from=MainApplication
3 3
 dependency1.to=Console
4 4
 dependency1.type=UsesDependency
5
-editor.fx.0.height=0
6
-editor.fx.0.width=0
5
+dependency2.from=UpdateDisplay
6
+dependency2.to=SwitchModes
7
+dependency2.type=UsesDependency
8
+editor.fx.0.height=977
9
+editor.fx.0.width=1920
7 10
 editor.fx.0.x=0
8
-editor.fx.0.y=0
11
+editor.fx.0.y=23
9 12
 objectbench.height=101
10
-objectbench.width=595
13
+objectbench.width=1896
11 14
 package.divider.horizontal=0.6
12
-package.divider.vertical=0.8358662613981763
13
-package.editor.height=543
14
-package.editor.width=493
15
-package.editor.x=35
15
+package.divider.vertical=0.8824809575625681
16
+package.editor.height=804
17
+package.editor.width=1794
18
+package.editor.x=0
16 19
 package.editor.y=23
17
-package.frame.height=716
18
-package.frame.width=619
19
-package.numDependencies=1
20
-package.numTargets=4
20
+package.frame.height=977
21
+package.frame.width=1920
22
+package.numDependencies=2
23
+package.numTargets=6
21 24
 package.showExtends=true
22 25
 package.showUses=true
23 26
 project.charset=UTF-8
@@ -27,30 +30,44 @@ readme.width=47
27 30
 readme.x=10
28 31
 readme.y=10
29 32
 target1.height=50
30
-target1.name=Memory
33
+target1.name=UpdateDisplay
31 34
 target1.showInterface=false
32 35
 target1.type=ClassTarget
33
-target1.width=80
34
-target1.x=190
35
-target1.y=10
36
+target1.width=120
37
+target1.x=130
38
+target1.y=130
36 39
 target2.height=50
37
-target2.name=Console
40
+target2.name=Memory
38 41
 target2.showInterface=false
39 42
 target2.type=ClassTarget
40 43
 target2.width=80
41
-target2.x=80
42
-target2.y=200
44
+target2.x=190
45
+target2.y=10
43 46
 target3.height=50
44
-target3.name=SciCalculator
47
+target3.name=Console
45 48
 target3.showInterface=false
46 49
 target3.type=ClassTarget
47
-target3.width=110
48
-target3.x=70
49
-target3.y=10
50
+target3.width=80
51
+target3.x=80
52
+target3.y=200
50 53
 target4.height=50
51
-target4.name=MainApplication
54
+target4.name=SwitchModes
52 55
 target4.showInterface=false
53 56
 target4.type=ClassTarget
54
-target4.width=120
55
-target4.x=70
56
-target4.y=70
57
+target4.width=110
58
+target4.x=10
59
+target4.y=130
60
+target5.height=50
61
+target5.name=SciCalculator
62
+target5.showInterface=false
63
+target5.type=ClassTarget
64
+target5.width=110
65
+target5.x=70
66
+target5.y=10
67
+target6.height=50
68
+target6.name=MainApplication
69
+target6.showInterface=false
70
+target6.type=ClassTarget
71
+target6.width=120
72
+target6.x=70
73
+target6.y=70