using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 机器人1
{
class Programe
{
static void Main(string[] args)
{
机器人1 r1 = new 机器人1();
r1.Name="小1";
r1.Eat(5);
while(true)
{
string str= Console.ReadLine();
r1.Speak(str);
Console.ReadKey();
}
}
}
class 机器人1
{
public string Name { get;set;}
private int FullLevel { get; set; }
public void SayHello()
{
Console.WriteLine("我叫:{0}",Name);
}
public void Eat (int foodCount)
{
if (foodCount > 100 )
{
return;
}
FullLevel = FullLevel+foodCount;
}
public void Speak(string str)
{
if(FullLevel <= 0)
{
Console.WriteLine("饿死了,说不了");
return;
}
if ( str.Contains("姓名") || str.Contains("名字"))
{
this.SayHello();
}
else if(str.Contains("女朋友"))
{
Console.WriteLine("年龄小,不考虑");
}
else
{
Console.WriteLine("听不懂");
}
FullLevel--;
}
}
}
WF案例机器人3
最新推荐文章于 2024-07-24 17:20:29 发布