Checking for forbidden words
I'm trying to put together a method that check for predefined vars. If a user tries to use a predefined variable not mapping is supposed to take place.
Method to check for predefined.
static boolean isVarAllowed()
if(st.getWord() == "e" || //getWord() returns String
st.getWord() == "pi" ||
st.getWord() == "sin" ||
st.getWord() == "cos" ||
st.getWord() == "log" ||
st.getWord() == "exp" ||
st.getWord() == "ans")
The mapping works, but I can't get it do deny over mapping. As it is now I'm loosing stuff like pi if the user tries to save stuff in pi. I other words, all mappings are allowed now. Well, as I said, that's not what I what. :-/
if(isVarAllowed() == true)
System.out.println("Test: It's mapping.");
map.put(st.getWord(), new Double(res));