using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace 面相对象聊天机器人
{
class Program
{
static void Main(string[] args)
{
机器人 r1 = new 机器人();
r1.Name = "Mother Fucker";
r1.Eat(10);
r1.SayHello();
while (true)
{
string str = Console.ReadLine();
r1.Speak(str);
}
}
}
class 机器人
{
public string Name{get;set;}
private int FullLevel{get;set;}
public void SayHello()
{
Console.WriteLine("大家好我叫{0}",Name);
}
public void Eat(int FoodCount)
{
if (FullLevel >= 100)
return;
FullLevel = FullLevel + FoodCount;
}
public string 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--;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace 面相对象聊天机器人
{
class Program
{
static void Main(string[] args)
{
机器人 r1 = new 机器人();
r1.Name = "Mother Fucker";
r1.Eat(10);
r1.SayHello();
while (true)
{
string str = Console.ReadLine();
r1.Speak(str);
}
}
}
class 机器人
{
public string Name{get;set;}
private int FullLevel{get;set;}
public void SayHello()
{
Console.WriteLine("大家好我叫{0}",Name);
}
public void Eat(int FoodCount)
{
if (FullLevel >= 100)
return;
FullLevel = FullLevel + FoodCount;
}
public string 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--;
}
}
}
using System;namespace 面相对象聊天机器人
{
class Program
{
static void Main(string[] args)
{
机器人 r1 = new 机器人();
r1.Name = "Mother Fucker";
r1.Eat(10);
r1.SayHello();
while (true)
{
string str = Console.ReadLine();
r1.Speak(str);
}
}
}
class 机器人
{
public string Name { get; set; }
private int FullLevel { get; set; }
public void SayHello()
{
Console.WriteLine("大家好我叫{0}", Name);
}
public void Eat(int FoodCount)
{
if (FullLevel >= 100)
return;
FullLevel = FullLevel + FoodCount;
}
public void Speak(string str)//Speak的返回值是void
{
if (FullLevel <= 0)
{
Console.WriteLine("饿死了,不说了");
return;
}
if (str.Contains("姓名") || str.Contains("名字"))
{
this.SayHello();
}
else if (str.Contains("女朋友"))
{
Console.WriteLine("年龄小,不考虑");
}
else
{
Console.WriteLine("听不懂!");
}
FullLevel--;
}
}
}