Policy mode
2016-12-18 20:20:09 2 举报
学设计模式呢,不是按照标准uml画的,管他呢,我舒服就行。
作者其他创作
大纲/内容
ZZGuack
+Quack()
FlyWithWings
Fly()
Duck
+fly:IFly+quack:IQuack
+PerformFly(){ fly.Fly();}+PerformQuack(){ quack.Quack();}+SetFly(IFly fly){ fly = fly;}+SetQuack(IQuack quack){ quack = quack;}
IQuack
MDuck
+MDuck(){ fly = new FlyNoWay(); quack = new ZZQuack();}
IFly
+Fly()
GDuck
+GDuck(){ fly = new FlyWithWings(); quack = new GGQuack();}
GGQuack
Duck duck = new MDuck();duck.fly();//Set fly when runningduck.SetFly(new FlyWithWings);duck.fly();
FlyNoWay
0 条评论
下一页