DesignPattern_Structural_Bridge

void Main()
{
    Bridge bridge = new Bridge();
    bridge.Set(new ShowA());
    bridge.Show();
    bridge.Set(new ShowB());
    bridge.Show();
}

class Bridge{
    IShow ishow;
    public void Set(IShow isw){ishow=isw;}
    public void Show(){
        ishow.Show();
    }
}
interface IShow{
    void Show();
}
class ShowA:IShow{
    public void Show(){}
}
class ShowB:IShow{
    public void Show(){}
}
时间: 2024-10-11 06:09:13

DesignPattern_Structural_Bridge的相关文章