Back to Examples
package edu.iuk.JeffV2;

import java.util.ArrayList;
import java.util.Scanner;

public class JeffV2 {

  public static void main(String[] args) {
    // Jeff
    int spaceIndex;
    String userName;
    String nextInput;
    ArrayList wordInput = new ArrayList();
    String[] helloVariables;
    String[] greetingQuestVar;
    String[] badVariables;
    String[] goodVariables;
    String[] goodbyeVariables;
    String[] disneyVariables;
    String[] laughingVariables;

    // Greeting
    helloVariables = new String[7];
    helloVariables[0] = "hello";
    helloVariables[1] = "hey";
    helloVariables[2] = "hi";
    helloVariables[3] = "howdy";
    helloVariables[4] = "yo";
    helloVariables[5] = "sup";
    helloVariables[6] = "hola";

    // Emotion
    greetingQuestVar = new String[7];
    greetingQuestVar[0] = "how are you";
    greetingQuestVar[1] = "how you doin";
    greetingQuestVar[2] = "what's up";
    greetingQuestVar[3] = "what is up";
    greetingQuestVar[4] = "what's going on";
    greetingQuestVar[5] = "how's it hanging";
    greetingQuestVar[6] = "sup";

    badVariables = new String[8];
    badVariables[0] = "not too good";
    badVariables[1] = "awful";
    badVariables[2] = "I want to die";
    badVariables[3] = "horrible";
    badVariables[4] = "i'm upset";
    badVariables[5] = "crappy";
    badVariables[6] = "shoot";
    badVariables[7] = "not okay";

    goodVariables = new String[11];
    goodVariables[0] = "not too bad";
    goodVariables[1] = "great";
    goodVariables[2] = "not too shabby";
    goodVariables[3] = "awesome";
    goodVariables[4] = "i'm happy";
    goodVariables[5] = "grand";
    goodVariables[6] = "excellent";
    goodVariables[7] = "i'm alright";
    goodVariables[8] = "fine";
    goodVariables[9] = "good";
    goodVariables[10] = "i'm okay";

    goodbyeVariables = new String[8];
    goodbyeVariables[0] = "bye";
    goodbyeVariables[1] = "see you";
    goodbyeVariables[2] = "smell you later";
    goodbyeVariables[3] = "adios";
    goodbyeVariables[4] = "catch you on the flip side";
    goodbyeVariables[5] = "peace out";
    goodbyeVariables[6] = "talk to you later";
    goodbyeVariables[7] = "goodbye";

    disneyVariables = new String[17];
    disneyVariables[0] = "disney";
    disneyVariables[1] = "pinnochio";
    disneyVariables[2] = "ariel";
    disneyVariables[3] = "little mermaid";
    disneyVariables[4] = "aladdin";
    disneyVariables[5] = "nemo";
    disneyVariables[6] = "monsters inc";
    disneyVariables[7] = "suite life";
    disneyVariables[8] = "mickey";
    disneyVariables[9] = "minnie";
    disneyVariables[10] = "donald duck";
    disneyVariables[11] = "goofy";
    disneyVariables[12] = "walt";
    disneyVariables[13] = "walt disney";
    disneyVariables[14] = "mickey mouse";
    disneyVariables[15] = "minnie mouse";
    disneyVariables[16] = "mickey mouse clubhouse";

    laughingVariables = new String[6];
    laughingVariables[0] = "lol";
    laughingVariables[1] = "haha";
    laughingVariables[2] = "hehe";
    laughingVariables[3] = "lmao";
    laughingVariables[4] = "lawl";
    laughingVariables[5] = "lul";

    //start Jeff Talk     Scanner name = new Scanner(System.in);
    System.out.println("Hello, I am Jeff. What is your name?");
    //user's name entered     userName = name.nextLine();
    System.out.println("Nice to meet you, " + userName);

    for (int ind = 0; ind < 9999999; ind = ind) {

      for (int i = 0; i < 999999999; i = i) {

        i = 0;
        Scanner next = new Scanner(System.in);
        nextInput = next.nextLine();
        nextInput = nextInput.toLowerCase();

        // clear array
        wordInput.clear();

        // put each word into the array

        for (int i1 = 0; nextInput.length() > 0; i1++) {

          // remove punctuation
          nextInput.replace(";", ".");
          nextInput.replace("!", ".");
          nextInput.replace("?", ".");

          // if there aren't any more spaces
          if (nextInput.indexOf(".") <= 0) {

            // put word into next array location
            wordInput.add(nextInput.substring(0));

            // clear nextInput
            nextInput = "";

          } else {

            // index of space
            spaceIndex = nextInput.indexOf(".");

            // put the word before the space into next array location
            wordInput.add(nextInput.substring(0, spaceIndex - 1));

            // remove the word and space from the sentence
            nextInput.replace(wordInput.get(wordInput.size() - 1) + ".", "");

          }

        }

        // take the word
        for (int word = 0; word < wordInput.size(); word++) {

          // and try it on hello variables
          for (int i1 = 0; i1 < helloVariables.length; i1++) {

            // if the word matches the hello variables
            if (wordInput.get(word).equals(helloVariables[i1])) {

              // say hello
              System.out.println("Hello, " + userName + "!");

              // add to the counter
              i++;

              // break the hello Variable loop
              break;

            }

          }

          for (int i1 = 0; i1 < greetingQuestVar.length; i1++) {

            if (wordInput.get(word).equals(greetingQuestVar[i1])) {

              System.out.println("I am doing well! How are you?");
              i++;
              break;

            }

          }

          if (i > 0) {

            break;

          }

          for (int i1 = 0; i1 < badVariables.length; i1++) {

            if (wordInput.get(word).equals(badVariables[i1])) {

              System.out.println("I am sorry to hear that.");
              i++;
              break;

            }

          }

          if (i > 0) {

            break;

          }

          for (int i1 = 0; i1 < goodVariables.length; i1++) {

            if (wordInput.get(word).equals(goodVariables[i1])) {

              System.out.println("I am glad to hear that!");
              i++;
              break;

            }

          }

          if (i > 0) {

            break;

          }

          for (int i1 = 0; i1 < disneyVariables.length; i1++) {

            if (wordInput.get(word).equals(disneyVariables[i1])) {

              System.out.println("Oh! I love Disney!");
              i++;
              break;

            }

          }

          for (int i1 = 0; i1 < laughingVariables.length; i1++) {

            if (wordInput.get(word).equals(laughingVariables[i1])) {

              System.out.println("I'm glad that I can make you laugh!");
              i++;
              break;

            }

          }
          if (i > 0) {
            break;

          }

          for (int i1 = 0; i1 < goodbyeVariables.length; i1++) {

            if (wordInput.get(word).equals(goodbyeVariables[i1])) {

              System.out.println("See you Later!");
              System.exit(0);

            }

          }

        }

        if (i == 0) {

          System.out.println("Sorry, I didn't quite catch that. Can you rephrase it?");

        }

      }

    }

  }

}
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!