110,536
社区成员
发帖
与我相关
我的任务
分享
public interface IAdviser
{
string Advise(int score);
}
public class Teacher : IAdviser
{
public string Advise(int score)
{
if (score < 60)
{
Console.Out.WriteLine(score+"老师说加油");
return "不及格";
}
else
{
Console.Out.WriteLine(score+"老师说不错");
return "及格";
}
}
}
public class OtherTeacher : IAdviser
{
public string Advise(int score)
{
Console.Out.WriteLine(score+"老师说:我就判你不及格,您能把我怎么着!");
return "不及格";
}
}
class MainClass
{
[STAThread]
private static void Main(string[] args)
{
//IAdviser teacher = new Teacher();
IAdviser teacher = new OtherTeacher();//在此做替换
Student s = new Student();
....
}
}