04-24-2014, 21:27
Sup fellas,
Its been awhile lol. Hows everybody doin?
Im living the dream! finishing my first year of college, getting all my finals done (feelsGoodMan.jpeg).
lol anyways, since ive been dominating my java class, 98%
, I wanted to create a program from scratch. WHICH IVE DONE SO FAR!
its a word filter (obviously). Ive only been able to find the spaces. Im stuck at this moment. I need some help from you fellers.
Driver:
Filter:
Should I use a for loop to look between each space given in the ArrayList to check and see if it matches a bad word? or am I making this to complicated? lol
Its been awhile lol. Hows everybody doin?
Im living the dream! finishing my first year of college, getting all my finals done (feelsGoodMan.jpeg).
lol anyways, since ive been dominating my java class, 98%
, I wanted to create a program from scratch. WHICH IVE DONE SO FAR!its a word filter (obviously). Ive only been able to find the spaces. Im stuck at this moment. I need some help from you fellers.
Driver:
Code:
package WordFilter;
/**
*
* @author Josh
*/
public class Driver {
public static void main(String[] args)
{
Filter filter = new Filter();
filter.buildSentence();
filter.removeWords();
}
}Filter:
Code:
package WordFilter;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author Josh
*/
public class Filter {
private String sentence;
public Filter()
{
this.sentence = new String();
}
/**
* lets the user enter a sentence then assigns it to a variable
*/
public void buildSentence() {
Scanner in = new Scanner(System.in);
System.out.println("Please enter a sentence to remove the badwords:");
sentence = in.nextLine();
}
/**
* Removes the bad words from the sentence variable
*/
public void removeWords() {
String[] badArray;
badArray = new String[2];
badArray[0] = "fuck";
badArray[1] = "shit";
toArray(sentence, badArray);
/*for(int i = 0; i < badArray.length; i++)
{
}*/
}
public void toArray(String sentence, String[] inArray)
{
int counter = 0;
ArrayList spaceCounter = new ArrayList();
String word = "";
while(!(counter == sentence.length()))
{
for(int i = 0; i < sentence.length(); i++)
{
if(sentence.charAt(i) == ' '){
spaceCounter.add(i);
}
counter++;
}
}
for(int j = 0; j < spaceCounter.size(); j++){
System.out.println(spaceCounter.get(j));
}
}
}Should I use a for loop to look between each space given in the ArrayList to check and see if it matches a bad word? or am I making this to complicated? lol


![[Image: ScHmIdTy56789.png]](http://g.bf3stats.com/ps3/pBtgtB23/ScHmIdTy56789.png)