I found some other threads about this same error but couldn't find anything that helped my specific case out. Anybody have any ideas? My assignment is to make a chatbot.
I'm also getting a '(' expected error at the end of my list of 'if statements', but I've checked all parenthesis and they're all matched up. Any ideas on that?
import java.util.Random;
/**
* Class to generate sentences
* Adam Taylor
*/
public class SentenceGenerator
{
private String[] nounArray = {"Josh", "Trent", "Kyle", "Megan", "Erin"};
private String[] verbArray = {"jumped", "fell", "flew", "walked", "steps"};
private String[] phraseArray = {"at a show", "in the back", "in a car",
"in the street", "out the door"};
private Random randGen = new Random();
public String generateRandomSentence()
{
String sentence =
nounArray[randGen.nextInt(nounArray.length)] + " " +
verbArray[randGen.nextInt(verbArray.length)] + " " +
phraseArray[randGen.nextInt(phraseArray.length)] + ".";
return sentence;
}
public static void main(String[] args)
{
SentenceGenerator sentenceGen = new SentenceGenerator();
for (int i=0; i<5; i++)
{
System.out.println(sentenceGen.generateRandomSentence());
}
}
public void (String[])
{
if (input.indexOf("hello", "hi", "How are you?") >= 0)
System.out.println("Hi, how are you doing today?");
}
Thanks so much for your time!
Bookmarks