using System;
namespace Pattern
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public abstract class strategy
{
protected string m_oldstr="";
protected string m_newstr="";
public void setOldString(string oldstr)
{
this.m_oldstr =oldstr;
}
public string getNewString()
{
return this.m_newstr;
}
public abstract void replace();
}
public class repA:strategy
{
public repA()
{
}
public override void replace()
{
this.m_newstr =this.m_oldstr+"aaaa";
}
}
public class repB:strategy
{
public repB()
{
}
public override void replace()
{
this.m_newstr =this.m_oldstr+"bbbb";
}
}
}
// 策略模式
// strategy r1=new repA();
// r1.setOldString("good");
// r1.replace();
// Console.WriteLine(r1.getNewString());
//
// repB r2=new repB();
// r2.setOldString("good");
// r2.replace();
// Console.WriteLine(r2.getNewString());