- 作者:xiaoxiao
- 发表时间:2020-12-23 10:52
- 来源:未知
//MyBridgeusing System;
//-------------------------------------------------Class Manager//parent classabstract class Manager{ //Method:KickOut abstract public void KickOut();};
//sonclass1:FemaleManagerclass FemaleManager:Manager{ override public void KickOut() { Console.WriteLine("Please Go Out!"); }};//sonclass2:MaleManagerclass MaleManager:Manager{ override public void KickOut() { Console.WriteLine("Out!Shit!"); }};//-------------------------------------------------Class Manager//-------------------------------------------------Class ChatRoomclass ChatRoom{ //manager to keep the room silent:Field private Manager chatroommanager;
//property public Manager ChatRoomManager { set{ chatroommanager=value; } }
//Method public void KickOut() { chatroommanager.KickOut(); }};//-------------------------------------------------Class ChatRoom//-------------------------------------------------TestAppclass TestApp{ public static void Main(string []args) { ChatRoom chatroom = new ChatRoom(); chatroom.ChatRoomManager=new FemaleManager(); chatroom.KickOut();
chatroom.ChatRoomManager=new MaleManager(); chatroom.KickOut();
while(true); }};
//-------------------------------------------------TestApp