|
@@ -2,6 +2,7 @@ import java.util.ArrayList;
|
2
|
2
|
|
3
|
3
|
public class Calculations
|
4
|
4
|
{
|
|
5
|
+ public static Console console = new Console();
|
5
|
6
|
public static ArrayList<String> library = new ArrayList<String>();
|
6
|
7
|
|
7
|
8
|
public Calculations(){
|
|
@@ -25,10 +26,12 @@ public class Calculations
|
25
|
26
|
|
26
|
27
|
}
|
27
|
28
|
|
28
|
|
- public static String getCommand(String userInput)
|
|
29
|
+ public static void getCommand(String userInput)
|
29
|
30
|
{
|
30
|
31
|
boolean foundCommand = false;
|
31
|
32
|
String command = "";
|
|
33
|
+ String result = "";
|
|
34
|
+
|
32
|
35
|
String[] inputArr = userInput.split(" ");
|
33
|
36
|
for(int i = 0; i < library.size(); i ++)
|
34
|
37
|
{
|
|
@@ -44,40 +47,110 @@ public class Calculations
|
44
|
47
|
switch(command)
|
45
|
48
|
{
|
46
|
49
|
case "multiply":
|
47
|
|
- Multiply(userInput);
|
|
50
|
+ result = Multiply(userInput);
|
48
|
51
|
break;
|
49
|
52
|
|
50
|
53
|
case "divide":
|
51
|
|
- Divide(userInput);
|
|
54
|
+ result = Divide(userInput);
|
52
|
55
|
break;
|
53
|
56
|
|
54
|
57
|
case "add":
|
55
|
|
- Add(userInput);
|
|
58
|
+ result = Add(userInput);
|
56
|
59
|
break;
|
57
|
60
|
|
58
|
61
|
case "subtract":
|
59
|
|
- Subtract(userInput);
|
|
62
|
+ result = Subtract(userInput);
|
60
|
63
|
break;
|
61
|
64
|
|
62
|
65
|
case "invertS":
|
63
|
|
- InvertSign(userInput);
|
|
66
|
+ result = InvertSign(userInput);
|
64
|
67
|
break;
|
65
|
68
|
|
66
|
69
|
case "invertN":
|
67
|
|
- InvertNumber(userInput);
|
|
70
|
+ result = InvertNumber(userInput);
|
68
|
71
|
break;
|
69
|
72
|
|
70
|
73
|
case "clear":
|
71
|
74
|
Clear();
|
72
|
75
|
break;
|
73
|
76
|
}
|
74
|
|
-
|
|
77
|
+ System.out.println(result);
|
|
78
|
+ //return result;
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ public static String Multiply(String userInput)
|
|
82
|
+ {
|
|
83
|
+ //take in a string
|
|
84
|
+ //take the numbers out of the string
|
|
85
|
+ //convert them to doubles
|
|
86
|
+ //perform the operation
|
|
87
|
+ //convert to string
|
|
88
|
+ //return string
|
|
89
|
+ return null;
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ public static String Divide(String userInput)
|
|
93
|
+ {
|
|
94
|
+ //take in a string
|
|
95
|
+ //take the numbers out of the string
|
|
96
|
+ //convert them to doubles
|
|
97
|
+ //perform the operation
|
|
98
|
+ //convert to string
|
|
99
|
+ //return string
|
|
100
|
+ return null;
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ public static String Add(String userInput)
|
|
104
|
+ {
|
|
105
|
+ //take in a string
|
|
106
|
+ //take the numbers out of the string
|
|
107
|
+ //convert them to doubles
|
|
108
|
+ //perform the operation
|
|
109
|
+ //convert to string
|
|
110
|
+ //return string
|
75
|
111
|
return null;
|
76
|
112
|
}
|
77
|
113
|
|
|
114
|
+ public static String Subtract(String userInput)
|
|
115
|
+ {
|
|
116
|
+ //take in a string
|
|
117
|
+ //take the numbers out of the string
|
|
118
|
+ //convert them to doubles
|
|
119
|
+ //perform the operation
|
|
120
|
+ //convert to string
|
|
121
|
+ //return string
|
|
122
|
+ return null;
|
|
123
|
+ }
|
|
124
|
+
|
78
|
125
|
public static String InvertSign(String userInput)
|
79
|
126
|
{
|
80
|
|
-
|
|
127
|
+ //take in a string
|
|
128
|
+ //take the numbers out of the string
|
|
129
|
+ //convert them to doubles
|
|
130
|
+ //perform the operation
|
|
131
|
+ //convert to string
|
|
132
|
+ //return string
|
|
133
|
+ return null;
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ public static String InvertNumber(String userInput)
|
|
137
|
+ {
|
|
138
|
+ //take in a string
|
|
139
|
+ //take the numbers out of the string
|
|
140
|
+ //convert them to doubles
|
|
141
|
+ //perform the operation
|
|
142
|
+ //convert to string
|
|
143
|
+ //return string
|
|
144
|
+ return null;
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ public static void Clear()
|
|
148
|
+ {
|
|
149
|
+ //take in a string
|
|
150
|
+ //take the numbers out of the string
|
|
151
|
+ //convert them to doubles
|
|
152
|
+ //perform the operation
|
|
153
|
+ //convert to string
|
|
154
|
+ //return string
|
81
|
155
|
}
|
82
|
|
-
|
83
|
156
|
}
|