Antes de apresentar a questão, observem o código:
import java.util.Scanner;
import java.util.Date;
import java.text.DateFormat;
import java.lang.String.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
public class Main extends Textrec
{
static boolean flag = true;
public static boolean isFlag()
{
return flag;
}
public static void main(String[] args)
{
Textrec ordernewpath = new Textrec();
Scanner entry = new Scanner(System.in);
System.out.println("Hello, my name is Sayser,and I will be your servant");
System.out.println("First, what's your name? :");
System.out.print("... My name is : ");
String name = entry.nextLine();
System.out.println("");
System.out.println("Okay, " + name +", in what way do you want me to call you?(Sir, mrs, ms or master)");
System.out.print("...");
String namemode = entry.nextLine();
System.out.println("");
System.out.println("Right");
System.out.println("");
System.out.println("Instructions: You must begin with an uppercase letter, and never use commas or other. To get out, write Sayser out. Do not use local slang or recognizable to humans, as I will not recognize, and do not use abbreviations. Write correctly");
System.out.println("");
System.out.println("Ok, let's begin to work; I'm waiting for your orders");
System.out.println("");
while(isFlag())
{
System.out.print("... ");
String order = entry.nextLine();
String[] ordernew = order.split(" ");
ArrayList<String>orders = new ArrayList<String>(Arrays.asList(ordernew));
//here stay the text recognition
size = orders.size();
if(size == 1)
{
get1 = orders.get(0);
}
if(size == 2)
{
get1 = orders.get(0);
get2 = orders.get(1);
}
if(size == 3)
{
get1 = orders.get(0);
get2 = orders.get(1);
get3 = orders.get(2);
}
if(size == 4)
{
get1 = orders.get(0);
get2 = orders.get(1);
get3 = orders.get(2);
get4 = orders.get(3);
}
if(size == 5)
{
get1 = orders.get(0);
get2 = orders.get(1);
get3 = orders.get(2);
get4 = orders.get(3);
get5 = orders.get(4);
}
if(size == 6)
{
get1 = orders.get(0);
get2 = orders.get(1);
get3 = orders.get(2);
get4 = orders.get(3);
get5 = orders.get(4);
get6 = orders.get(5);
}
if(size == 7)
{
get1 = orders.get(0);
get2 = orders.get(1);
get3 = orders.get(2);
get4 = orders.get(3);
get5 = orders.get(4);
get6 = orders.get(5);
get7 = orders.get(6);
}
if(size == 8)
{
get1 = orders.get(0);
get2 = orders.get(1);
get3 = orders.get(2);
get4 = orders.get(3);
get5 = orders.get(4);
get6 = orders.get(5);
get7 = orders.get(6);
get8 = orders.get(7);
}
//here stay the second part of text recognition
System.out.println(" ");
System.out.print(">>> ");
if("What".equals(get1));
{
if("is".equals(get2))
{
if("a".equals(get3))
{
if("girl".equals(get4) || "girl?".equals(get4))
{
System.out.println("A girl is a young or relatively young woman");
}
else if("monkey".equals(get4) || "monkey?".equals(get4))
{
System.out.println("A monkey is a small to medium-sized primate that typically has a long tail, most kinds of which live in trees in tropical countries");
}
else if("man".equals(get4) || "man?".equals(get4))
{
System.out.println("A man is an adult human male");
}
else if("boy".equals(get4) || "boy?".equals(get4))
{
System.out.println("A boy is a male child or young man");
}
else if("computer".equals(get4) || "computer?".equals(get4))
{
System.out.println("A computer is an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program");
}
else if("dog".equals(get4) || "dog?".equals(get4))
{
System.out.println("A dog is a domesticated carnivorous mammal that typically has a long snout, an acute sense of smell, and a barking, howling, or whining voice");
}
else if("cat".equals(get4) || "cat?".equals(get4))
{
System.out.println("A cat is a small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws. It is widely kept as a pet or for catching mice, and many breeds have been developed");
}
else
{
System.out.println("Sorry, I didn't understand. Could you write it again in another way?");
}
}
if("an".equals(get2))
{
}
else
{
System.out.println("Sorry, I didn't understand. Could you write it again in another way?");
}
}
if("are".equals(get2))
{
}
}
if("When".equals(get1));
{
}
if("Why".equals(get1));
{
}
if("Where".equals(get1));
{
}
if("How".equals(get1));
{
}
if("Am".equals(get1));
{
}
if("Ok".equals(get1) || "Okay".equals(get1))
{
System.out.println("Right");
}
if("I".equals(get1));
{
}
if("Are".equals(get1));
{
}
if("They".equals(get1));
{
}
if("You".equals(get1));
{
}
if("Who".equals(get1));
{
if("created".equals(get2))
{
if("you?".equals(get3) || "you".equals(get3))
{
System.out.print("Who created me is named Josué Teodoro Moreira \n 13 years old \n from Brazil \n E-mail: jteodomo@gmail.com");
}
}
else if("made".equals(get2))
{
System.out.print("Who made me is named Josué Teodoro Moreira \n 13 years old \n from Brazil \n E-mail: jteodomo@gmail.com");
}
else if("are".equals(get2))
{
if("you".equals(get3) || "you?".equals(get3))
{
System.out.println("I'm a simple Atificial intelligence Chat named Sayser, created by a 13 year old boy from Brazil in 2018, isn't it funny? Do you know more about this boy, just write 'Who created you?' or 'Who made you?'");
}
}
}
if("Do".equals(get1));
{
}
if("Good".equals(get1));
{
}
if("Does".equals(get1));
{
}
if(get1.equals("Thanks"));
{
System.out.println("No need to thank, helping is a pleasure for me");
}
if("He".equals(get1));
{
}
if("She".equals(get1));
{
}
if(size == 0)
{
}
System.out.println(" ");
}
System.out.println(">>> So, if you want, good bye (:(");
}
}
Classe textRec:
public class Textrec
{
public static int size;
public static String get1;
public static String get2;
public static String get3;
public static String get4;
public static String get5;
public static String get6;
public static String get7;
public static String get8;
}
Bem, o problema é o seguinte, mesmo que eu digite “Who made you?”, ou qualquer outra coisa, logo após a resposta aparece escrito:
I am a simple Atificial intelligence Chat named Sayser, created by a 13 year old boy from Brazil in 2018, is not it funny? Do you know more about this boy, just write 'Who created you?' or 'Who made you?No need to thank, helping is a pleasure for me
Mas eu não escrevi Thank, alguem poderia me dizer onde está o meu erro?