123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import java.util.ArrayList;
-
- public class Calculations
- {
- public static Console console = new Console();
- public static ArrayList<String> library = new ArrayList<String>();
-
- public Calculations(){
-
- library.add("multiply");
- library.add("divide");
- library.add("subtract");
- library.add("add");
- library.add("COS");
- library.add("SIN");
- library.add("TAN");
- library.add("invertS");
- library.add("invertN");
- library.add("factorial");
- library.add("switchunit");
- library.add("clear");
- library.add("storeM");
- library.add("resetM");
- library.add("recallM");
- library.add("displayM");
-
- }
-
- public static void getCommand(String userInput)
- {
- boolean foundCommand = false;
- String command = "";
- String result = "";
-
- String[] inputArr = userInput.split(" ");
- for(int i = 0; i < library.size(); i ++)
- {
- String currCommand = library.get(i);
- if(currCommand.equalsIgnoreCase(inputArr[0]))
- {
- command = currCommand;
- foundCommand = true;
- break;
- }
- }
-
- switch(command)
- {
- case "multiply":
- result = Multiply(userInput);
- break;
-
- case "divide":
- result = Divide(userInput);
- break;
-
- case "add":
- result = Add(userInput);
- break;
-
- case "subtract":
- result = Subtract(userInput);
- break;
-
- case "invertS":
- result = InvertSign(userInput);
- break;
-
- case "invertN":
- result = InvertNumber(userInput);
- break;
-
- case "clear":
- Clear();
- break;
- }
- System.out.println(result);
- //return result;
- }
-
- public static ArrayList<Double> getNumbers(String userInput){
- ArrayList<Double> results = new ArrayList<Double>();
- //takes in a string
- //finds the first occurence of a number
- //store it as a double ( left )
- //add this to the arraylist
- //find the second occurence of a number
- //store it as a double (right)
- //add this to the array list
- //if the size of the arraylist is 2
- //return the array list
- //else return null
- return results;
- }
-
- public static String Multiply(String userInput)
- {
- //perform the operation
- //convert to string
- //return string
- return null;
- }
-
- public static String Divide(String userInput)
- {
- //perform the operation
- //convert to string
- //return string
- return null;
- }
-
- public static String Add(String userInput)
- {
- //perform the operation
- //convert to string
- //return string
- return null;
- }
-
- public static String Subtract(String userInput)
- {
- //perform the operation
- //convert to string
- //return string
- return null;
- }
-
- public static String InvertSign(String userInput)
- {
- //perform the operation
- //convert to string
- //return string
- return null;
- }
-
- public static String InvertNumber(String userInput)
- {
- //perform the operation
- //convert to string
- //return string
- return null;
- }
-
- public static void Clear()
- {
- //reset the default value to 0
- }
- }
|