I've made this console program as a small start for an up comming text based AI, in this code, I'm trying to find the sentence that the user inputs, and then display a message from that input.
My problem here is that, if i type in "Hello" as the first word and press enter, it works as i should, but if i type in "Hi" as the first word, nothing happens... If i then try to type in "Hi" as the second input, it comes with the matching output.
My problem here is that, if i type in "Hello" as the first word and press enter, it works as i should, but if i type in "Hi" as the first word, nothing happens... If i then try to type in "Hi" as the second input, it comes with the matching output.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alicia
{
class Program
{
static void Main(string[] args)
{
string firstName = "Alicia";
string[] myText = new string[6];
myText[0] = "Hello";
myText[1] = "Hi";
myText[2] = "Hello, who are you?";
myText[3] = "Hi, who are you?";
myText[4] = "Hello, what is your name?";
myText[5] = "Hi, what is your name?";
Console.WriteLine("Hello User");
if(Console.ReadLine() == myText[0])
{
Console.WriteLine("What is your name User?");
}
else if(Console.ReadLine() == myText[1])
{
Console.WriteLine("What is your name User?");
}
else if(Console.ReadLine() == myText[2])
{
Console.WriteLine("I'm {0}, who are you?", firstName);
}
else if(Console.ReadLine() == myText[3])
{
Console.WriteLine("I'm {0}, who are you?", firstName);
}
else if(Console.ReadLine() == myText[4])
{
Console.WriteLine("My name is {0}, what is yours?", firstName);
}
else if (Console.ReadLine() == myText[5])
{
Console.WriteLine("My name is {0}, what is yours?", firstName);
}
}
}
}
Comment