Bladeren bron

Merge branch 'master' of https://git.zipcode.rocks/jonathan-hinds/ZCW-MacroLabs-OOP-ScientificCalculator

Elliott Stansbury 6 jaren geleden
bovenliggende
commit
43a96356d5
4 gewijzigde bestanden met toevoegingen van 159 en 18 verwijderingen
  1. 83
    0
      Calculations.java
  2. 19
    18
      Console.java
  3. 17
    0
      MainApplication.java
  4. 40
    0
      package.bluej

+ 83
- 0
Calculations.java Bestand weergeven

@@ -0,0 +1,83 @@
1
+import java.util.ArrayList;
2
+
3
+public class Calculations
4
+{
5
+    public static ArrayList<String> library = new ArrayList<String>();
6
+    
7
+    public Calculations(){
8
+   
9
+    library.add("multiply");
10
+    library.add("divide");
11
+    library.add("subtract");
12
+    library.add("add");
13
+    library.add("COS");
14
+    library.add("SIN");
15
+    library.add("TAN");
16
+    library.add("invertS");
17
+    library.add("invertN");
18
+    library.add("factorial");
19
+    library.add("switchunit");
20
+    library.add("clear");
21
+    library.add("storeM");
22
+    library.add("resetM");
23
+    library.add("recallM");
24
+    library.add("displayM");
25
+        
26
+    }
27
+
28
+    public static String getCommand(String userInput)
29
+    {
30
+        boolean foundCommand = false;
31
+        String command = "";
32
+        String[] inputArr = userInput.split(" ");
33
+        for(int i = 0; i < library.size(); i ++)
34
+        {
35
+            String currCommand = library.get(i);
36
+            if(currCommand.equalsIgnoreCase(inputArr[0]))
37
+            {
38
+                command = currCommand;
39
+                foundCommand = true;
40
+                break;
41
+            }
42
+        }
43
+        
44
+        switch(command)
45
+        {
46
+            case "multiply":
47
+                Multiply(userInput);
48
+            break;
49
+            
50
+            case "divide":
51
+                Divide(userInput);
52
+            break;
53
+            
54
+            case "add":
55
+                Add(userInput);
56
+            break;
57
+            
58
+            case "subtract":
59
+                Subtract(userInput);
60
+            break;
61
+            
62
+            case "invertS":
63
+                InvertSign(userInput);
64
+            break;
65
+            
66
+            case "invertN":
67
+                InvertNumber(userInput);
68
+            break;   
69
+            
70
+            case "clear":
71
+                Clear();
72
+            break;
73
+        }
74
+        
75
+        return null;
76
+    }
77
+    
78
+    public static String InvertSign(String userInput)
79
+    {
80
+        
81
+    }
82
+   
83
+}

+ 19
- 18
Console.java Bestand weergeven

@@ -7,26 +7,27 @@ import java.util.Scanner;
7 7
  */
8 8
 public class Console {
9 9
 
10
-    public static void print(String output, Object... args) {
11
-        System.out.printf(output, args);
12
-    }
10
+    
11
+    //public static void print(String output, Object... args) {
12
+    //    System.out.printf(output, args);
13
+    //}
13 14
 
14
-    public static void println(String output, Object... args) {
15
-        print(output + "\n", args);
16
-    }
15
+    //public static void println(String output, Object... args) {
16
+    //    print(output + "\n", args);
17
+    //}
17 18
 
18
-    public static String getStringInput(String prompt) {
19
-        Scanner scanner = new Scanner(System.in);
20
-        println(prompt);
21
-        String userInput = scanner.nextLine();
22
-        return userInput;
23
-    }
19
+    //public static String getStringInput(String prompt) {
20
+    //    Scanner scanner = new Scanner(System.in);
21
+    //    println(prompt);
22
+    //    String userInput = scanner.nextLine();
23
+    //    return userInput;
24
+    //}
24 25
 
25
-    public static Integer getIntegerInput(String prompt) {
26
-        return null;
27
-    }
26
+    //public static Integer getIntegerInput(String prompt) {
27
+    //    return null;
28
+    //}
28 29
 
29
-    public static Double getDoubleInput(String prompt) {
30
-        return null;
31
-    }
30
+    //public static Double getDoubleInput(String prompt) {
31
+    //    return null;
32
+    //}
32 33
 }

+ 17
- 0
MainApplication.java Bestand weergeven

@@ -0,0 +1,17 @@
1
+ 
2
+
3
+/**
4
+ * Created by leon on 2/9/18.
5
+ */
6
+public class MainApplication {
7
+    public static void main(String[] args) {
8
+        //Console.println("Welcome to my calculator!");
9
+        //String s = Console.getStringInput("Enter a string");
10
+        //Integer i = Console.getIntegerInput("Enter an integer");
11
+        //Double d = Console.getDoubleInput("Enter a double.");
12
+
13
+        //Console.println("The user input %s as a string", s);
14
+        //Console.println("The user input %s as a integer", i);
15
+        //Console.println("The user input %s as a d", d);
16
+    }
17
+}

+ 40
- 0
package.bluej Bestand weergeven

@@ -1,4 +1,5 @@
1 1
 #BlueJ package file
2
+<<<<<<< HEAD
2 3
 editor.fx.0.height=709
3 4
 editor.fx.0.width=800
4 5
 editor.fx.0.x=480
@@ -15,6 +16,24 @@ package.frame.height=709
15 16
 package.frame.width=619
16 17
 package.numDependencies=0
17 18
 package.numTargets=2
19
+=======
20
+editor.fx.0.height=0
21
+editor.fx.0.width=0
22
+editor.fx.0.x=0
23
+editor.fx.0.y=0
24
+objectbench.height=200
25
+objectbench.width=595
26
+package.divider.horizontal=0.6
27
+package.divider.vertical=0.6854103343465046
28
+package.editor.height=444
29
+package.editor.width=493
30
+package.editor.x=35
31
+package.editor.y=23
32
+package.frame.height=716
33
+package.frame.width=619
34
+package.numDependencies=0
35
+package.numTargets=3
36
+>>>>>>> 5c782a9d95f3f9208ab5ec62241ab490d899062b
18 37
 package.showExtends=true
19 38
 package.showUses=true
20 39
 project.charset=UTF-8
@@ -24,16 +43,37 @@ readme.width=47
24 43
 readme.x=10
25 44
 readme.y=10
26 45
 target1.height=50
46
+<<<<<<< HEAD
27 47
 target1.name=OrderOfOperations
28 48
 target1.showInterface=false
29 49
 target1.type=ClassTarget
30 50
 target1.width=140
31 51
 target1.x=70
32 52
 target1.y=70
53
+=======
54
+target1.name=Calculations
55
+target1.showInterface=false
56
+target1.type=ClassTarget
57
+target1.width=100
58
+target1.x=120
59
+target1.y=150
60
+>>>>>>> 5c782a9d95f3f9208ab5ec62241ab490d899062b
33 61
 target2.height=50
34 62
 target2.name=Console
35 63
 target2.showInterface=false
36 64
 target2.type=ClassTarget
37 65
 target2.width=80
66
+<<<<<<< HEAD
38 67
 target2.x=80
39 68
 target2.y=200
69
+=======
70
+target2.x=20
71
+target2.y=150
72
+target3.height=50
73
+target3.name=MainApplication
74
+target3.showInterface=false
75
+target3.type=ClassTarget
76
+target3.width=120
77
+target3.x=70
78
+target3.y=70
79
+>>>>>>> 5c782a9d95f3f9208ab5ec62241ab490d899062b