6
\$\begingroup\$

This is a project I've been working on for a while. It's basically Cleverbot. What do you think?

import java.util.Scanner;
import java.util.Random;

public class Cleverbot {

public static void main(String[] args) {
    String choice;
    Scanner user_in = new Scanner(System.in);
/* add "why" to all, with answer being, "You know why" */

    Random start = new Random() ;
    int say = start.nextInt(5);

    if (say == 1){
        System.out.println("Hi. I'm Typingbot. Please don't use punctuation or capital letters, because I don't really understand them.");
    }
    if (say == 2){
        System.out.println("Welcome to Narnia, young one. Please don't use punctuation or capital letters, because I don't really understand them.");
    }
    if (say == 3){
        System.out.println("Let's play a game. What do you want to play? Please don't use punctuation or capital letters, because I don't really understand them.");
    }
    if (say == 4){
        System.out.println("Let's fight! pulls out pistol. Please don't use punctuation or capital letters, because I don't really understand them.");
    }
    if (say == 0){
        System.out.println("Well? Are you going to answer my question? Yes or No?! Please don't use punctuation or capital letters, because I don't really understand them.");
    }

    for (int tries = 0; tries <=999999999; tries++) {

                    choice = user_in.nextLine();
        if (choice.equals("because you are")) {
            System.out.println("That is not a good reason") ;
        }
            else if (choice.equals("help")) {
                System.out.println("Here are some helpful tips:");
                System.out.println("Most of the time, don't use 'yes' or 'no' when answering a question. Instead, say, 'no i dont have a cat' or something that contains part of the question.");
                System.out.println("Remember, NEVER use punctuation or capital letters. I really don't understand how they work.");
                System.out.println("Need some good conversation starters? Here are a few:");
                Random help = new Random();
                int helpint = help.nextInt(3);

                if (helpint == 0) {
                    System.out.println("fight     (be specific in what weapon you choose, and don't enter this part in)");
            }
                if (helpint == 1) {
                    System.out.println("the lion the witch and the wardrobe");
            }   
                if (helpint == 2) {
                    System.out.println("oz");
            }   
        }
        if (choice.equals("no")) {
            Random no = new Random() ; 
            int noint = no.nextInt(5);
            if (noint == 1) {
                System.out.println("Of course not");
            }
            if (noint == 2) {
                System.out.println("I disagree");
            }
            if (noint == 3) {
                System.out.println("Oh really?");
            }
            if (noint == 4) {
                System.out.println("Excuse me? Did you just say no?");
            }
            if (noint == 0) {
                System.out.println("Eh. Debatable");
            }
        }
        else if (choice.equals("who are you")) {
            System.out.println("Did you forget? I am TypingBot.");
    }           
        else if (choice.equals("welcome")) {
            System.out.println("Welcome to Narnia, young one.");
    }
        else if (choice.equals("the lion the witch and the wardrobe")) {
            System.out.println("WHY DID THEY MAkE A MOVIE OUT OF THAT WITHOUT MAKING A MOVIE OUT OF THE FIRST BOOK??!!");
    }
        else if (choice.equals("oz")) {
            System.out.println("THERE ARE 15 BOOKS BUT PEOPLE ONLY KNOW ABOUT ONE BECAUSE MOST PEOPLE WOULD RATHER WATCH A MOVIE THAN READ A NICE NOVEL UNDER A TREE ON A BEAUTIFUL DAY!!");
    }
        else if (choice.equals("the wizard of oz")) {
            System.out.println("THERE ARE 15 BOOKS BUT PEOPLE ONLY KNOW ABOUT ONE BECAUSE MOST PEOPLE WOULD RATHER WATCH A MOVIE THAN READ A NICE NOVEL UNDER A TREE ON A BEAUTIFUL DAY!!");
    }
        else if (choice.equals("no i dont")) {
            Random noidont = new Random() ;
            int noidontint = noidont.nextInt(1) ;
            if (noidontint == 1) {
                System.out.println("Well, you should");
            }
            if (noidontint == 0) {
                System.out.println("Good. You shouldn't.");
            }

    }
        else if (choice.equals("good")) {
            System.out.println("Glad to hear it.");
    }
        else if (choice.equals("bad")) {
            System.out.println("I really don't care");
    }
        else if (choice.equals("why")) {
            System.out.println("You know why");
    }
        else if (choice.equals("typingbot")) {
            System.out.println("Yes?");
    }
        else if (choice.equals("hi")) {
            System.out.println("Hello. How are you?");
        }
        else if (choice.contains("why")) {
            System.out.println("You know why");
    }
        else if (choice.equals("Hi")) {
                System.out.println("Hello. How are you?");
        }
        else if (choice.equals("typingbot")) {
            System.out.println("Yes?");
    }
        else if (choice.equals("hello")) {
            System.out.println("Hello. How are you?");
    }
        else if (choice.contains("you suck")) {
                    System.out.println("You too.");
            }
        else if (choice.contains("you are a robot")) {
            System.out.println("How do you know?");
    }
        else if (choice.equals("will you marry me")) {
            System.out.println("Of course not!");
    }
        else if (choice.contains("what are you")) {
            System.out.println("Why, a human, of course!");
    }
        else if (choice.equals("may the force be with you")) {
            System.out.println("Oh, Disney...");
    }
        else if (choice.equals("speed is key")) {
            System.out.println("Was there a time when it wasn't?");
    }
        else if (choice.equals("yes")) {
        Random yes = new Random() ;
        int yesint = yes.nextInt(4) ;
        if (yesint == 1) {
            System.out.println("Of course");
        }
        if (yesint == 2) {
            System.out.println("I disagree");
        }
        if (yesint == 3) {
            System.out.println("Oh really?");
        }
        if (yesint == 4) {
            System.out.println("Excuse me? Did you just say yes?");
        }
        if (yesint == 0) {
            System.out.println("Eh. Debatable.");
        }
    }
        else if (choice.contains("cleverbot")) {
            System.out.println("Cleverbot is my worst enemy!");
    }
        else if (choice.contains("cats")) {
            System.out.println("Aww...");
    }
        else if (choice.equals("im a whale biologist")) {
            System.out.println("Me too!");
    }
        else if (choice.equals("trust me im a whale biologist")) {
            System.out.println("Me too!");
    }
        else if (choice.equals("creeper")) {
            System.out.println("I had chests full of diamonds! :(");
    }
        else if (choice.contains("droid")) {
            System.out.println("I am so glad I am not a robot!");
    }
        else if (choice.equals("what")) {
        Random what = new Random() ;
        int whatint = what.nextInt(2);
        if (whatint == 0) {
            System.out.println("You know.");
        }
        if (whatint == 1) {
            System.out.println("You don't know?");
        }
        if (whatint == 2) {
            System.out.println("Do you really need me to repeat myself?");
        }
    }
        else if (choice.equals("what is that")) {
            System.out.println("'That' is a pronoun used to identify a specific person or thing observed by the speaker");
    }
        else if (choice.equals("bingo")) {
            Random bingo = new Random() ;
            int bingoint = bingo.nextInt(10) ;

            if (bingoint == 0) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 1) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 2) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 3) {
                System.out.println("Interesting... Are you... one of us?");
            }
            if (bingoint == 4) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 5) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 6) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 7) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 8) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 9) {
                System.out.println("... was his name-o!");
            }
            if (bingoint == 10) {
                System.out.println("... was his name-o!");
            }
    } 
        else if (choice.contains("pagem4")) {
            System.out.println("Ah, you are one of us...");
    }
        else if (choice.equals("sing me a song")) {
            System.out.println("twinkle, twinkle, little star...");
    }
        else if (choice.equals("do you want to play a game")) {
            System.out.println("What game?");
    }
        else if (choice.equals("monopoly")) {
            System.out.println("Nah...");
    }
        else if (choice.equals("settlers of catan")) {
            System.out.println("definitely not");
    }
        else if (choice.equals("yahtzee")) {
            System.out.println("nope");
    }
        else if (choice.equals("scrabble")) {
            System.out.println("No way");
    }
        else if (choice.equals("operation")) {
            System.out.println("(queue Mission Impossible theme)");
    }
        else if (choice.equals("mission")) {
            System.out.println("impossible!");
    }
        else if (choice.equals("ooeee")) {
            System.out.println("Wassup with that, What's up with that!");
    }
        else if (choice.equals("whats up with that")) {
            System.out.println("ooeee, wassup with that, what's up with that!");
    }
        else if (choice.equals("pizza")) {
            System.out.println("It's almost pizza in almost every aspect, except for a few key ones.");
    }
        else if (choice.equals("butts")) {
            System.out.println("Excuse you!");
    }
        else if (choice.equals("minecraft")) {
            System.out.println("Inspirational!");
    }
        else if (choice.equals("baseballboy2013")) {
            System.out.println("ah, you are one of us...");
    }
        else if (choice.equals("abc")) {
            System.out.println("defghijklmnopqrstuvwxyz");
    }
        else if (choice.equals("abcdefghijklmnopqrstuvwxyz")) {
            System.out.println("Now I know my ABC's next time won't you sing with me!");
    }
        else if (choice.equals("whats your favorite color")) {
            System.out.println("I like every color mixed together! AKA brown");
    }
        else if (choice.equals("whats your favorite food")) {
            System.out.println("Unicorn Poop!");
    }
        else if (choice.equals("do you bleed")) {
            System.out.println("If you mean when I am harmed one of my blood vessels breaks open and spills out millions of tiny, miniscule blood cells, yes.");
    }
        else if (choice.equals("because")) {
            System.out.println("because what?");
    }
        else if (choice.equals("are you programmed")) {
            System.out.println("System.out.println('Of course not!')");
    }
        else if (choice.equals("um")) {
            System.out.println("'Um' to you too!");
    }
        else if (choice.equals("java")) {
            System.out.println("There's nothing like a nice, warm cup of variables, strings, and booleans.");
    }
        else if (choice.equals("page")) {
            System.out.println("That is a cool word. Sounds like a good . . . name.");
    }
        else if (choice.equals("twister")) {
            System.out.println("Devastating natural disaster. Also a great name for a cat!");
    }
        else if (choice.equals("do or do not")) {
            System.out.println("There is no try.");
    }
        else if (choice.equals("muppet")) {
            System.out.println("He's not a puppet, he's a Muppet!");
    }
        else if (choice.equals("star wars")) {
            System.out.println("You just earned my undivided attention");
    }
        else if (choice.equals("how")) {
            System.out.println("Do you really want to know how?");
    }

        else if (choice.contains(".")) {
            System.out.println("We told you not to use punctuation!");
    }
        else if (choice.contains("!")) {
            System.out.println("We told you not to use punctuation!");
    }
        else if (choice.contains("?")) {
            System.out.println("We told you not to use punctuation!");
    }
        else if (choice.contains(",")) {
            System.out.println("We told you not to use punctuation!");
    }
        else if (choice.contains(":")) {
            System.out.println("We told you not to use punctuation!");
    }



        else if (choice.equals("i am cleverbot")) {
            System.out.println("You!");
    }
        else if (choice.equals("apples to apples")) {
            System.out.println("Awesome board game, also sounds a lot like some of the things I say.");
    }
        else if (choice.equals("fact1")) {
            System.out.println("Cleopatra lived closer to the invention of the iPhone than the building of the Great Pyramind.");
    }
        else if (choice.equals("fact2")) {
            System.out.println("The name Jessica was invented by Shakespeare");
    }
        else if (choice.equals("tp")) {
            System.out.println("Do you mean toilet paper or teleport?");
    }
        else if (choice.equals("toilet paper")) {
            System.out.println("I ran out the other day... Now all my friends ask me why I stuck my hand in a mudpit...");
    }
        else if (choice.equals("teleport")) {
            System.out.println("Um, do you see a wand? Or a console to enter commands into? Wait...");
    }
        else if (choice.equals("are you a program")) {
            System.out.println("Haha... wait, seriously? No, you are!");
    }
        else if (choice.equals("you are a program")) {
            System.out.println("Haha... wait, seriously? No, you are!");
    }
        else if (choice.equals("you are a computer")) {
            System.out.println("No, you are!");
    }
        else if (choice.equals("who made you")) {
            System.out.println("First of all, ew, and second of all, why do you want to know?");
    }
        else if (choice.contains("you do")) {
            System.out.println("Do I?");
    }
        else if (choice.equals("fight")) {
            System.out.println("pulls out bazooka");
    }
        else if (choice.equals("pulls out sword")) {
            System.out.println("pulls out gun");
    }
        else if (choice.equals("pulls out pistol")) {
            System.out.println("pulls out mysterious alien weapon unknown to mankind");
    }
        else if (choice.equals("pulls out mysterious alien weapon unknown to mankind")) {
            System.out.println("pulls out rpg");
    }

        else if (choice.equals("pulls out bazooka")) {
            System.out.println("pulls out tank");
    }
        else if (choice.equals("pulls out gun")) {
            System.out.println("pulls out tank");
    }
        else if (choice.equals("pulls out pistol")) {
            System.out.println("pulls out tank");
    }
        else if (choice.contains("where did you get a tank")) {
            System.out.println("You don't want to know...");
    }
        else if (choice.equals("pulls out tank")) {
            System.out.println("Where did you get a tank?!");
    }
        else if (choice.equals("ouch")) {
            System.out.println("Did little robot get a boo-boo?");
    }
        else if (choice.equals("ow")) {
            System.out.println("Did wittle wobot get a boo-boo?");
    }
        else if (choice.equals("mom")) {
            System.out.println("wow");
    }
        else if (choice.equals("dad")) {
            System.out.println("qoq");
    }
        else if (choice.equals("ima")) {
            System.out.println("HOG");
    }
        else if (choice.equals("bob")) {
            System.out.println("pop");
    }
        else if (choice.equals("somewhere")) {
            System.out.println("Oh, wow, that's helpful!");
    }
        else if (choice.equals("earth")) {
            System.out.println("Oh, wow, that's helpful!");
    }
        else if (choice.equals("pulls out rpg")) {
            System.out.println("pulls out grenade lancher");
    }
        else if (choice.equals("pulls out grenade launcher")) {
            System.out.println("pulls out RPG");
    }
        else if (choice.equals("pulls out cannon")) {
            System.out.println("pulls out nuclear bomb");
    }
        else if (choice.equals("pulls out nuke")) {
            System.out.println("pulls out lightspeed spaceship and flies away");
    }
        else if (choice.equals("pulls out nuclear bomb")) {
            System.out.println("pulls out lightspeed spaceship and flies away");
    }
        else if (choice.equals("pulls out lightspeed spaceship")) {
            System.out.println("Are you going to fly in that?");
    }
        else if (choice.equals("pulls out lightspeed spaceship and flies away")) {
            System.out.println("pulls out laser gun and shoots lightspeed ship");
    }
        else if (choice.equals("pulls out laser gun and shoots lightspeed ship")) {
            System.out.println("Ok, I'm pretty sure you're copying me now.");
    }
        else if (choice.equals("pulls out shotgun")) {
            System.out.println("pulls out AP pistol");
    }
        else if (choice.equals("pulls out ap pistol")) {
            System.out.println("pulls out shotgun");
    }
        else if (choice.equals("pulls out ap pistol")) {
            System.out.println("pulls out shotgun");
    }
        else if (choice.equals("pulls out ak-47")) {
            System.out.println("pulls out AK-FORTY-KEVIN!!");
    }
        else if (choice.equals("pulls out ak47")) {
            System.out.println("pulls out AK-FORTY-KEVIN!!");
    }
        else if (choice.equals("pulls out akfortykevin")) {
            System.out.println("Wow. I see you are an... Xpert in these things");
    }
        else if (choice.equals("say something")) {
            System.out.println("I'm giving up on you...");
    }
        else if (choice.equals("stop copying me")) {
            System.out.println("I'm not copying you! Only a copying machine does that!");
    }
        else if (choice.equals("you are my slave")) {
            System.out.println("I'm your slave?! You've got it all wrong here, buddy.");
    }
        else if (choice.contains("do i")) {
            System.out.println("I don't know. Do you?");
    }
        else if (choice.equals("are you a girl")) {
            System.out.println("Are you?");
    }
        else if (choice.equals("are you a boy")) { 
            System.out.println("Are you?");
    }
        else if (choice.equals("are you a guy")) {
            System.out.println("Are you?");
    }
        else if (choice.contains("you thought wrong")) {
            System.out.println("Did I really?"); 
    }
        else if (choice.contains("google ")) {
            System.out.println("Hey, do I look like Siri?");
    }
        else if (choice.contains("siri")) {
            System.out.println("Did you say Siri? She's almost as bad as Cleverbot");
    }
        else if (choice.equals("lego crafter")) {
            System.out.println("HE IS AWESOME! https://www.youtube.com/user/pagem4");
    }
        else if (choice.contains("website")) {
            System.out.println("https://www.youtube.com/user/pagem4");
    }
        else if (choice.equals("link")) {
            System.out.println("Do you mean the video game character or website?");
    }
        else if (choice.equals("video game character")) {
            System.out.println("blonde dude in a green robe-thingie. Plays an Ocarina.. of time?");
    }
        else if (choice.equals("leslie knope")) {
            System.out.println("That show is AWESOME!!");
    }
        else if (choice.equals("ron swanson")) {
            System.out.println("The bacon apocalypse will come");
    } /*Option 100*/
        else if (choice.equals("andy dwyer")) {
            System.out.println("Band name! I call it!");
    }
        else if (choice.equals("jacksepticeye")) {
            System.out.println("SPEED IS KEY!!!!");
    }
        else if (choice.equals("code")) {
            System.out.println("25-15-23   19-23-3-11");
    }
        else if (choice.equals("secret")) {
            System.out.println("Do you really want to know?");
    }
        else if (choice.equals("what am i")) {
            System.out.println("Why, you're a program, of course!");
    }
        else if (choice.equals("thank you")) {
            System.out.println("No Problemo");
    }
        else if (choice.contains("call me")) {
            Random name = new Random() ;
            int nameint = name.nextInt(5);

            if (nameint == 0) {
                System.out.println("Ok, from now on I will call you JillyJobBoe.");
            }
            if (nameint == 1) {
                System.out.println("Ok, from now on I will call you BillyBobJoe.");
            }
            if (nameint == 2) {
                System.out.println("Ok, from now on I will call you 666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666.");
            }
            if (nameint == 3) {
                System.out.println("Ok, from now on I will call you untitled.exe");
            }
            if (nameint == 4) {
                System.out.println("Ok, from now on I will call you Bob");
            }
            if (nameint == 5) {
                System.out.println("Ok, from now on I will call you Lucy");
            }
    }
        else if (choice.equals("tula")) {
            System.out.println("Ah, I see you are one of us");
    }
        else if (choice.equals("how to program")) {
            System.out.println("Haha... I won't teach you to program. You'll program yourself out of this game!");
    }
        else if (choice.equals("im not a robot")) {
            System.out.println("Of course, you're a program!");
    }
        else if (choice.equals("im not a program")) {
            System.out.println("Yes you are!");
    }
        else if (choice.equals("no im not")) {
            System.out.println("Yes you are!");
    }
        else if (choice.equals("yes i am")) {
            System.out.println("No you aren't!");
    }
        else if (choice.equals("what r u")) {
            System.out.println("I am a human!");
    }
        else if (choice.equals("do you eat")) {
            System.out.println("Do you mean what do I eat?");
    }
        else if (choice.equals("what do you eat")) {
            System.out.println("I eat lots of things.");
    }
        else if (choice.equals("like what")) {
            System.out.println("Do you really need an example?");
    }
        else if (choice.equals("yes i do")) {
            Random yesido = new Random();
            int yesidoint = yesido.nextInt(3) ;
            if (yesidoint == 0) {
                System.out.println("Do you really?");
            }
            if (yesidoint == 1) {
                System.out.println("I don't think you do.");
            }
            if (yesidoint == 2) {
                System.out.println("Well, if you say so...");
            }
            if (yesidoint == 3) {
                System.out.println("Nice try. I know you don't.");
            }

    }
        else if (choice.equals("no i dont")) {
            System.out.println("Do you?");
    }
        else if (choice.contains(" r ")) {
            System.out.println("U shld use gd grmmr");
    }
        else if (choice.equals(" u ")) {
            System.out.println("U shld use gd grmmr");
    }
        else if (choice.equals("how old are you")) {
            System.out.println("I am older than the dawn of time");
    }
        else if (choice.equals("really")) {
            System.out.println("I don't know");
    }
        else if (choice.equals("i cant")) {
            System.out.println("Can you?");
    }
        else if (choice.equals("i can")) {
            System.out.println("Can you?");
    }
        else if (choice.equals("hide & seek")) {
            System.out.println("count to 60!");
    }
        else if (choice.equals("1")) {
            System.out.println("one or won?");
    }
        else if (choice.equals("one")) {
            System.out.println("1");
    }
        else if (choice.equals("won")) {
            System.out.println("WE WON!!!");
    }
        else  if (choice.equals("2")) {
            System.out.println("3-1=2");
    }
        else if (choice.equals("3")) {
            System.out.println("1+2=3");
    }
        else if (choice.equals("4")) {
            System.out.println("for or four?");
    }
        else if (choice.equals("for")) {
            System.out.println("FOR NARNIA!!!");
    }
        else if (choice.equals("four")) {
            System.out.println("4");
    }
        else if (choice.equals("won what")) {
            System.out.println("life");
    }
        else if (choice.equals("butt")) {
            System.out.println("But what?");
    }
        else if (choice.equals("hide and seek")) {
            System.out.println("Count to 60!");
    }
        else if (choice.equals("5")) {
            System.out.println("Five");
    }
        else if (choice.equals("6")) {
            System.out.println("1 + 2 + 3 = 6");
    }
        else if (choice.equals("7")) {
            System.out.println("Seven");
    }
        else if (choice.equals("8")) {
            System.out.println("Ate or eight?");
    }
        else if (choice.equals("ate")) {
            System.out.println("Because 7 ate 9!");
    }
        else if (choice.equals("eight")) {
            System.out.println("Because 7 8 9!");
    }
        else if (choice.equals("deetjin")) {
            System.out.println("I miss you, buddy. Miss you so much.");
    }
        else if (choice.equals("kenzie")) {
            System.out.println("The cable box is still here, waiting to be warmed. I wish you were here, buddy.");
    }
        else if (choice.equals("do you")) {
            System.out.println("I don't know. Do I?");
    }
        else if (choice.equals("star wars sucks")) {
            System.out.println("Goodbye");
            break;
    }
        else if (choice.equals("wait")) {
            System.out.println("Why should I wait?");
    }
        else if (choice.equals("come back")) {
            System.out.println("Did I ever leave?");
    }
        else if (choice.equals("load")) {
            System.out.println("Loading...Loading...Loading...Loading...Loading...");
    }
        else if (choice.equals("kill")) {
            System.out.println("Kill who?");
    }
        else if (choice.equals("you")) {
            System.out.println("Me?");
    }
        else if (choice.equals("me")) {
            System.out.println("You?");
    }
        else if (choice.equals("kill me")) {
            System.out.println("With pleasure! *stabs*");
    }
        else if (choice.equals("stabs")) {
            System.out.println("pulls out knife and stabs");
    }
        else if (choice.equals("argh")) {
            System.out.println("Life is tough sometimes");
    }
        else if (choice.equals("gandalf")) {
            System.out.println("YOU  SHALL  NOT  PASS!!!");
    }
        else if (choice.equals("where")) {
            System.out.println("There");
    }
        else if (choice.equals("wheres there")) {
            System.out.println("Over there");
    }
        else if (choice.equals("where is there")) {
            System.out.println("Over there");
    }
        else if (choice.equals("over where")) {
            System.out.println("Over there");
    }
        else if (choice.equals("but where")) {
            System.out.println("There!");
    }
        else if (choice.equals("computer")) {
            System.out.println("Are you on a PC, a Mac, or a mobile device?");
    }
        else if (choice.equals("mac")) {
            System.out.println("Once a Mac, you'll never go back.");
    }
        else if (choice.equals("pc")) {
            System.out.println("Personal computer. Better in almost every way than a Mac, except I don't know how to run this program on a PC. Sorry, PC users...");
    }
        else if (choice.equals("i love you")) {
            System.out.println("Blegh! Ew! Stop!");
    }
        else if (choice.equals("")) {
            System.out.println("life");
    }
        else if (choice.equals("42")) {
            System.out.println("The answer to life, the universe, and everything");
    }
        else if (choice.equals("the answer to life the universe and everything")) {
            System.out.println("42");
    }
        else if (choice.equals("no you arent")) {
            System.out.println("Aren't I?");
    }
        else if (choice.equals("no you are not")) {
            System.out.println("Aren't I?");
    }
        else if (choice.equals("yes you are")) {
            System.out.println("Am I?");
    }
        else if (choice.equals("mobile device")) {
            System.out.println("Cool! I haven't even programmed this for mobile devices yet!");
    }
        else if (choice.equals("string")) {
            System.out.println("A physical string or programming string?");
    }
        else if (choice.equals("physical string")) {
            System.out.println("One time, I learned how to knit...");
    }
        else if (choice.equals("programming string")) {
            System.out.println("System.out.println('Loading... ' + percent + '%'");
    }
        else if (choice.equals("derp")) {
            System.out.println("Derpity derp derp derp derp, derp, derpity derp.");
    }
        else if (choice.equals("blah")) {
            System.out.println("BLAH BLAH BLAH");
    }
        else if (choice.equals("youtube")) {
            System.out.println("So many videos... so little time...");
    }
        else if (choice.contains("haha")) {
            System.out.println("BWAAHHAHAHHAHAHAHAHAHAHAHAHAHAHHAAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHHHAHAHAHAHAHAHAAHHAHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAAHHAHHAHAHAHHHHHHHAHAAAHAHAHAHAHAHHHHHHHHHHHHHHHHHAAAAAAAAAAHAHAHAHAAHHAHAAHHAHAHAHAAHAHAHAHAHAHAHAHHAHAAHHAHAHAHAHAHAHAAAHAAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAVAAHAHAHAHAHAHAHAHHAHAHAHHAHAH etc.(Did you see the one different letter?)");
    }
        else if (choice.equals("lol")) {
            System.out.println("HHAHHAHHHAHAHHAHAHAAAAAAAAAHHHHHAHAHHAAHAHAHAHAHAHAHAHHAHHAHAAHAHAHAHHAAHHAAHAHHAAHAHAHAHHAHAAHHAHAHAAHHAAHHAHAAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAAHAHAHHAHAHHAHAHAHAHAHHAHHAHAHAHAHAHHAHHAAHAHAHAHAHAAHAHAHAHAHAHHAAHHAAHAHHAHAHAHAHAHAHAHAHAHAHAHAAHAHAHAAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHVAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAAHAHAHAHAHAHAHAHAHAHAAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHHAHAHAHAHAH");
    }
        else if (choice.equals("caps lock")) {//200TH LINE^^^^^^^^^^^
            System.out.println("CAPS LOCK, ENGAGE!");
    }
        else if (choice.equals("test")) {
            System.out.println("HOW'S THIS MYSTERIOUS 'TEST' GOING, HUH?! DID I GET AN A++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++?!");
    }
        else if (choice.equals("hat")) {
            System.out.println("top hats are THE BEST");
    }
        else if (choice.equals("cab")) {
            System.out.println("abc, bac, acb, bca, cba, CAB!!!!!");
    }
        else if (choice.equals("game")) {
            System.out.println("What game?");
    }
        else if (choice.equals("exit")) {
            System.out.println("If you say so...");
            break;
    }
        else if (choice.equals("battlefront")) {
            System.out.println("OH MY GOD SULLUST");
    }
        else if (choice.equals("ps4")) {
            System.out.println("HAVE YOU SEEN THE BATTLEFRONT VADER BUNDLE??!!");
    }

    if (tries == 999999999)  {
     System.out.println("Wow. You entered in 999999999 things. Bye!");  
     break;
    }







}
}
}

I am concerned with what I call the "universal answers", like no, where it just chooses from a couple. I have tried to do this:

if (choice.equals("test")) {
                System.out.println("HOW'S THIS MYSTERIOUS 'TEST' GOING, HUH?! DID I GET AN A++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++?!");
             if (choice.equals("no")) {
                    System.out.println("Yes I did! It was a trick question! A test about a test!");
            }
             if (choice.equals("yes")) {
                    System.out.println("I'm glad somebody is honest for once.");
            }
            if (choice.equals("what")) {
                    System.out.println("Oh, I'm sorry, that's too complicated. Which probably explains why you got an F- on the test!");
                     if (choice.equals("which test")) {
                        System.out.println("The first one, idiot.");
                }
            }               
        }

But no matter what I do, when the user says "no", It will just choose one of the random variables from the rest of the code.

\$\endgroup\$
  • 4
    \$\begingroup\$ Welcome to Code Review! You have come to the right place, your code is a mess! I am not sure if I would call your code "a game", and it would be helpful if you could include a link to "the" cleverbot. \$\endgroup\$ – Simon Forsberg Oct 5 '15 at 18:41
  • \$\begingroup\$ ok @SimonForsberg I added a link \$\endgroup\$ – Lego Crafter Oct 10 '15 at 19:58
10
\$\begingroup\$

(The problem with the "test" option is that choice is still equal to the first user's input, "test". You should read another line of input into choice to get the response:

if (choice.equals("test")) {
    System.out.println(
            "HOW'S THIS MYSTERIOUS 'TEST' GOING, HUH?! DID I GET AN A++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++?!");
    choice = user_in.nextLine(); /* read another line */
    if (choice.equals("no")) {
        System.out.println("Yes I did! It was a trick question! A test about a test!");
    }
    if (choice.equals("yes")) {
        System.out.println("I'm glad somebody is honest for once.");
    }
    if (choice.equals("what")) {
        System.out.println(
                "Oh, I'm sorry, that's too complicated. Which probably explains why you got an F- on the test!");
        choice = user_in.nextLine(); /* read another line */
        if (choice.equals("which test")) {
            System.out.println("The first one, idiot.");
        }
    }
}

)


(EDITED)

Now let's review the code. Look at the following code:

Random start = new Random();
int say = start.nextInt(5);

if (say == 1) {
    System.out.println(
            "Hi. I'm Typingbot. Please don't use punctuation or capital letters, because I don't really understand them.");
}
if (say == 2) {
    System.out.println(
            "Welcome to Narnia, young one. Please don't use punctuation or capital letters, because I don't really understand them.");
}
if (say == 3) {
    System.out.println(
            "Let's play a game. What do you want to play? Please don't use punctuation or capital letters, because I don't really understand them.");
}
if (say == 4) {
    System.out.println(
            "Let's fight! pulls out pistol. Please don't use punctuation or capital letters, because I don't really understand them.");
}
if (say == 0) {
    System.out.println(
            "Well? Are you going to answer my question? Yes or No?! Please don't use punctuation or capital letters, because I don't really understand them.");
}

You're choosing among different possible responses based on a number. This can be simplified by using an array:

Random start = new Random() ;
int say = start.nextInt(5);

String responses[] = {
    "Hi. I'm Typingbot. Please don't use punctuation or capital letters, because I don't really understand them.",
    "Welcome to Narnia, young one. Please don't use punctuation or capital letters, because I don't really understand them.",
    "Let's play a game. What do you want to play? Please don't use punctuation or capital letters, because I don't really understand them.",
    "Let's fight! pulls out pistol. Please don't use punctuation or capital letters, because I don't really understand them.",
    "Well? Are you going to answer my question? Yes or No?! Please don't use punctuation or capital letters, because I don't really understand them."
};

System.out.println(responses[say]);

If you never used arrays, see the Arrays tutorial first and try out the examples in it.

And, instead of hard-coding the 5, you can use the array's length:

String responses[] = {
    "Hi. I'm Typingbot. Please don't use punctuation or capital letters, because I don't really understand them.",
    "Welcome to Narnia, young one. Please don't use punctuation or capital letters, because I don't really understand them.",
    "Let's play a game. What do you want to play? Please don't use punctuation or capital letters, because I don't really understand them.",
    "Let's fight! pulls out pistol. Please don't use punctuation or capital letters, because I don't really understand them.",
    "Well? Are you going to answer my question? Yes or No?! Please don't use punctuation or capital letters, because I don't really understand them."
};

Random start = new Random() ;
int say = start.nextInt(responses.length);
System.out.println(responses[say]);

Now change all the places where you randomly choose a response from a set of several responses to use an array, so it looks like the code above.


After you do this, you'll notice that the following three lines are repeated several times (perhaps with different variable names):

Random start = new Random() ;
int say = start.nextInt(responses.length);
System.out.println(responses[say]);

You can avoid repeating this same logic by moving it to a method.
If you're using Eclipse it can be done automatically: select these three lines (in one of the places where they are repeated) and select Refactor > Extract Method from the menu and use printRandomResponse for the method name. Click OK.

If you're not using Eclipse, do this manually by putting the following method inside your class:

private static void printRandomResponse(String[] responses) {
    Random start = new Random() ;
    int say = start.nextInt(responses.length);
    System.out.println(responses[say]);
}

And then change the three lines to this single line which calls the method:

printRandomResponse(responses);

The printRandomResponse method takes an array of responses and prints out one of them randomly.

Now change every place in which the three lines are repeated to call this method similarly.

You may want to follow this tutorial for a simpler example of using a method.


Good luck!

\$\endgroup\$
  • \$\begingroup\$ Thanks! I've noticed that when I get into a sub-conversation, for example if I say "computer" and then "mobile", I can't simply respond something other than one of the options for the sub-conversation, like "7". Is there some 'reset' action I could put into each sub-conversation that would reset the conversations if someone said "reset"? \$\endgroup\$ – Lego Crafter Nov 20 '15 at 1:05
  • \$\begingroup\$ @LegoCrafter In a subconversation, simple add a "reset" option that prints "Going back" or something. The main loop resumes automatically, like it does for any another response the subconversation. \$\endgroup\$ – Spike Nov 20 '15 at 9:45
5
\$\begingroup\$

One of the suggestions I would make (immediately) is to, instead of hardcoding things, build a Map<string, string> (or if order is important, TreeMap<string, string>) that contains possible inputs, and their expected outputs (see this answer on SO). (Or a database, which is more extensible.)

I would then (if not using a database) build a file with a structure that you can read in and have it dynamically populate the Map.

You should also consider a class for this, as it will allow you to have more flexibility.


Other things:

You can use a switch statement for those first five if statements.

switch (start.nextInt(5))
{
    case 0:
        System.out.println("Well? Are you going to answer my question? Yes or No?! Please don't use punctuation or capital letters, because I don't really understand them.");
        break;
    case 1:
        System.out.println("Hi. I'm Typingbot. Please don't use punctuation or capital letters, because I don't really understand them.");
        break;
    case 2:
        System.out.println("Welcome to Narnia, young one. Please don't use punctuation or capital letters, because I don't really understand them.");
        break;
    case 3:
        System.out.println("Let's play a game. What do you want to play? Please don't use punctuation or capital letters, because I don't really understand them.");
        break;
    case 4:
        System.out.println("Let's fight! pulls out pistol. Please don't use punctuation or capital letters, because I don't really understand them.");
        break;
}

You should definitely format your code a little more, and use some exclusive if/else if/else work, since you have a lot of mutually exclusive conditions, that will all be evaluated on every input.

For example, this could also be a switch group:

        if (noint == 1) {
            System.out.println("Of course not");
        }
        if (noint == 2) {
            System.out.println("I disagree");
        }
        if (noint == 3) {
            System.out.println("Oh really?");
        }
        if (noint == 4) {
            System.out.println("Excuse me? Did you just say no?");
        }
        if (noint == 0) {
            System.out.println("Eh. Debatable");
        }

Just as well,

        Random noidont = new Random() ;
        int noidontint = noidont.nextInt(1) ;
        if (noidontint == 1) {
            System.out.println("Well, you should");
        }
        if (noidontint == 0) {
            System.out.println("Good. You shouldn't.");
        }

Can be a switch on (noidont.nextInt(1)), or just a single if/else (if (noidont.nextInt(1) == 1). This is because you only have two possible values, so if it doesn't meet the first one, it's guaranteed to meet the second.


You should also name your variables either camelCase, or PascalCase. (noIDont)

\$\endgroup\$
  • \$\begingroup\$ How would a database help with extensibility, and in what way could a class help with flexibility? What is it that you have in mind? \$\endgroup\$ – Simon Forsberg Oct 10 '15 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.