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