using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
机器人 r1 = new 机器人();
r1.Name = "小陈";
r1.Ful_level = 10;
r1.SayHello();
while (true)
{
string str = Console.ReadLine();
r1.Speak(str);
}
}
}
class 机器人
{
public string Name;
public int Ful_level;
public void SayHello()
{
Console.WriteLine("你好,我叫{0},很高兴认识你!", Name);
}
public void Speak(String str)
{
if (Ful_level > 10)
{
Console.WriteLine("撑死了,不吃了"); Ful_level--;
}
else if (str.Contains("吃"))
{
Ful_level++;
if (Ful_level > 10)
{
Console.WriteLine("撑死了,不吃了"); Ful_level--;
}
}
else if (Ful_level == 0)
{
Console.WriteLine("饿死了,不说了");
}
else if ( str.Contains("名字"))
{
this.SayHello(); Ful_level--;
}
else if (str.Contains("女朋友"))
{
Console.WriteLine("年龄小,不考虑"); Ful_level--;
}
else if (str.Contains(""))
{
Console.WriteLine("说话啊"); Ful_level--;
}
else
{
Console.WriteLine("听不懂"); Ful_level--;
}
}
}
}
C#简易聊天机器人(控制台程序)
猜你喜欢
转载自blog.csdn.net/sinat_37676560/article/details/65448834
今日推荐
周排行