I am trying to create a profanity test for my app, but it seems to malfunction!! why?
code:
public boolean filter(String message)
{
String[] words={*CUSS WORDS*};
for(int i=0; i< (words.length-1); i++ )
{
if(message.indexOf(words[i].toLowerCase())!= -1)
{
return true;
}
}
return false;
}
OR Another code (BUT SAME FUNCTION):
public boolean filter(String message)
{
String[] words={CUSS WORDS};
for(int i=0; i< (words.length-1); i++ )
{
if(message.contains(words[i}))
{
return true;
}
}
return false;
}
So the PROBLEM IS: I tried these 2 pieces of codes with similar results. For example for "Fuck", if I enter "fu" into my app it stops it from being entered or for "ass", if I enter "as" it stop it from being entered! (Filter works to stop any profanity from entering the chat)