封装用户的功能,对于执行功能的部分,用户接口是一个状态,不同用户决定了执行功能的不同
public
class
User
...
{
private string m_userRight;
public string UserRight
...{
get
...{
return m_userRight;
}
set
...{
m_userRight=value;
}
}
}

public
abstract
class
UserAction
...
{
public UserAction()
...{
}
protected User m_user;
public abstract void Search()
...{
}
}

public
class
AdminAction:UserAction
...
{
public override void Search()
...{
if(m_user.UserRight.ToLower()=="admin")
MessageBox.Show("you are administrator");
}
}

public
class
SuperAction:UserAction
...
{
public override void Search()
...{
if(m_user.UserRight.ToLower()=="super")
MessageBox.Show("you are super");
}
}

public
class
NormalAction:UserAction
...
{
public override void Search()
...{
if(m_user.UserRight.ToLower()=="normal")
MessageBox.Show("your are normal");
}
}